diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2006-05-30 09:38:19 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2006-05-30 09:38:19 +0000 |
| commit | 987d9e05f2c502138ecf648d76c02886f0534740 (patch) | |
| tree | 59797bc5c3224a1802492e8ceaaa60971c8f8659 | |
| parent | 6986a1d0083c106c11095e250d46dbd2dacfa857 (diff) | |
Fixed shortcut and default focus for message dialogs (STR #1298).
Default focus is now on the button that also reacts to the 'Enter' key. This should avoid confusion about Enter triggering the button1 or button 0.
Also, I changed the shortcut call to the new convention which works on MSWindows. I don't have a Linux system right now for testing... .
Fixed focus issues (STR #1286, STR #1289, STR #1296)
fl_xfocus was not always updated, making widgets or even whole windows loose focus when any focus changes were not accompanied by a click into the same window. Also, Fl_Tabs would not redraw correctly if focus returned to the active tab.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5165 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | CHANGES | 3 | ||||
| -rw-r--r-- | FL/Fl_Tabs.H | 1 | ||||
| -rw-r--r-- | src/Fl.cxx | 18 | ||||
| -rw-r--r-- | src/Fl_Tabs.cxx | 26 | ||||
| -rw-r--r-- | src/fl_ask.cxx | 4 | ||||
| -rw-r--r-- | src/fl_encoding_latin1.cxx | 4 | ||||
| -rw-r--r-- | src/screen_xywh.cxx | 2 | ||||
| -rw-r--r-- | test/sudokurc.h | 32 |
8 files changed, 56 insertions, 34 deletions
@@ -1,5 +1,8 @@ CHANGES IN FLTK 1.1.8 + - Fixed shortcut and default focus for message + dialogs (STR #1298) + - Fixed focus issues (STR #1286, STR #1289, STR #1296) - Fixed window resizing in OS X (STR #1297) - In Fluid, declarations starting with the keyword 'typedef', 'class', or 'struct' are now treated diff --git a/FL/Fl_Tabs.H b/FL/Fl_Tabs.H index b11143be0..3f88c2a63 100644 --- a/FL/Fl_Tabs.H +++ b/FL/Fl_Tabs.H @@ -37,6 +37,7 @@ class FL_EXPORT Fl_Tabs : public Fl_Group { int tab_height(); void draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int sel=0); protected: + void redraw_tabs(); void draw(); public: diff --git a/src/Fl.cxx b/src/Fl.cxx index 60be2bd98..2064ce3ac 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -78,6 +78,11 @@ int Fl::visible_focus_ = 1, Fl::dnd_text_ops_ = 1; +Fl_Window *fl_xfocus; // which window X thinks has focus +Fl_Window *fl_xmousewin;// which window X thinks has FL_ENTER +Fl_Window *Fl::grab_; // most recent Fl::grab() +Fl_Window *Fl::modal_; // topmost modal() window + // // 'Fl::version()' - Return the API version number... // @@ -526,6 +531,14 @@ void Fl::focus(Fl_Widget *o) { if (o != p) { Fl::compose_reset(); focus_ = o; + // make sure that fl_xfocus is set to the top level window + // of this widget, or fl_fix_focus will clear our focus again + if (o) { + Fl_Window *win = 0, *w1 = o->window(); + while (w1) { win=w1; w1=win->window(); } + if (win) fl_xfocus = win; + } + // take focus from the old focused window fl_oldfocus = 0; int old_event = e_number; e_number = FL_UNFOCUS; @@ -557,11 +570,6 @@ void Fl::pushed(Fl_Widget *o) { pushed_ = o; } -Fl_Window *fl_xfocus; // which window X thinks has focus -Fl_Window *fl_xmousewin;// which window X thinks has FL_ENTER -Fl_Window *Fl::grab_; // most recent Fl::grab() -Fl_Window *Fl::modal_; // topmost modal() window - static void nothing(Fl_Widget *) {} void (*Fl_Tooltip::enter)(Fl_Widget *) = nothing; void (*Fl_Tooltip::exit)(Fl_Widget *) = nothing; diff --git a/src/Fl_Tabs.cxx b/src/Fl_Tabs.cxx index 37fcdf7ab..02bac39a1 100644 --- a/src/Fl_Tabs.cxx +++ b/src/Fl_Tabs.cxx @@ -119,6 +119,18 @@ Fl_Widget *Fl_Tabs::which(int event_x, int event_y) { return 0; } +void Fl_Tabs::redraw_tabs() +{ + int H = tab_height(); + if (H >= 0) { + H += Fl::box_dy(box()); + damage(FL_DAMAGE_SCROLL, x(), y(), w(), H); + } else { + H = Fl::box_dy(box()) - H; + damage(FL_DAMAGE_SCROLL, x(), y() + h() - H, w(), H); + } +} + int Fl_Tabs::handle(int event) { Fl_Widget *o; @@ -138,12 +150,15 @@ int Fl_Tabs::handle(int event) { o = which(Fl::event_x(), Fl::event_y()); if (event == FL_RELEASE) { push(0); + if (o && Fl::visible_focus() && Fl::focus()!=this) { + Fl::focus(this); + redraw_tabs(); + } if (o && value(o)) { set_changed(); do_callback(); } } else push(o); - if (Fl::visible_focus() && event == FL_RELEASE) Fl::focus(this); return 1; case FL_MOVE: { int ret = Fl_Group::handle(event); @@ -168,14 +183,7 @@ int Fl_Tabs::handle(int event) { Fl::event() == FL_KEYBOARD || Fl::event() == FL_FOCUS || Fl::event() == FL_UNFOCUS) { - int H = tab_height(); - if (H >= 0) { - H += Fl::box_dy(box()); - damage(FL_DAMAGE_SCROLL, x(), y(), w(), H); - } else { - H = Fl::box_dy(box()) - H; - damage(FL_DAMAGE_SCROLL, x(), y() + h() - H, w(), H); - } + redraw_tabs(); if (Fl::event() == FL_FOCUS || Fl::event() == FL_UNFOCUS) return 0; else return 1; } else return Fl_Group::handle(event); diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx index 454ecff77..6ab7e53d5 100644 --- a/src/fl_ask.cxx +++ b/src/fl_ask.cxx @@ -80,7 +80,7 @@ static Fl_Window *makeform() { o->labelcolor(FL_BLUE); } button[0] = new Fl_Button(310, 70, 90, 23); - button[0]->shortcut("^["); + button[0]->shortcut(FL_Escape); button[0]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP); button[1] = new Fl_Return_Button(210, 70, 90, 23); button[1]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP); @@ -198,6 +198,8 @@ static int innards(const char* fmt, va_list ap, resizeform(); + if (button[1]->visible() && !input->visible()) + button[1]->take_focus(); message_form->hotspot(button[0]); message_form->show(); int r; diff --git a/src/fl_encoding_latin1.cxx b/src/fl_encoding_latin1.cxx index 5191b69d4..5f2aa7af3 100644 --- a/src/fl_encoding_latin1.cxx +++ b/src/fl_encoding_latin1.cxx @@ -30,8 +30,8 @@ #include <stdlib.h> #include "flstring.h" -#ifdef __APPLE__
-
+#ifdef __APPLE__ + // These function assume a western code page. If you need to support // scripts that are not part of this code page, you might want to // take a look at FLTK2, which uses utf8 for text encoding. diff --git a/src/screen_xywh.cxx b/src/screen_xywh.cxx index ede0f5969..836c4258a 100644 --- a/src/screen_xywh.cxx +++ b/src/screen_xywh.cxx @@ -58,7 +58,7 @@ static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM) { // GetMonitorInfo(mon, &mi); if (fl_gmi(mon, &mi)) { screens[num_screens] = mi.rcWork; - num_screens ++;
+ num_screens ++; } return TRUE; } diff --git a/test/sudokurc.h b/test/sudokurc.h index 9a6bc9079..0cea5434d 100644 --- a/test/sudokurc.h +++ b/test/sudokurc.h @@ -1,16 +1,16 @@ -//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by icons.rc
-//
-#define IDI_ICON 101
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by icons.rc +// +#define IDI_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif |
