diff options
| author | Manolo Gouy <Manolo> | 2012-12-17 17:44:15 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2012-12-17 17:44:15 +0000 |
| commit | 46abc078b451f07a2105a8d3338e70bac37bd0ec (patch) | |
| tree | 6a90355505fa34d85e11c5ea5f5215b7f3b1d1b6 /src | |
| parent | 3eb27ccf3ef0fe7b6e20cf095d30d976d88288fe (diff) | |
Mac OS: improved text input support with visible display of marked text in text widgets.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9761 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Text_Display.cxx | 2 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 45 | ||||
| -rw-r--r-- | src/Fl_compose.cxx | 6 |
3 files changed, 28 insertions, 25 deletions
diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 03be48e60..5f261c5b0 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -1943,7 +1943,7 @@ void Fl_Text_Display::draw_string(int style, if (Fl::focus() == (Fl_Widget*)this) background = selection_color(); else background = fl_color_average(color(), selection_color(), 0.4f); } else if (style & HIGHLIGHT_MASK) { - if (Fl::focus() == (Fl_Widget*)this) background = fl_color_average(color(), selection_color(), 0.5f); + if (Fl::focus() == (Fl_Widget*)this) background = fl_color_average(color(), selection_color(), Fl::compose_state ? 0.3f : 0.5f); else background = fl_color_average(color(), selection_color(), 0.6f); } else background = color(); foreground = fl_contrast(styleRec->color, background); diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 02119ddcb..6525a89e2 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -44,6 +44,7 @@ extern "C" { #include <FL/Fl_Sys_Menu_Bar.H> #include <FL/Fl_Printer.H> #include <FL/Fl_Input_.H> +#include <FL/Fl_Secret_Input.H> #include <FL/Fl_Text_Display.H> #include <stdio.h> #include <stdlib.h> @@ -1674,7 +1675,6 @@ static void q_set_window_title(NSWindow *nsw, const char * name, const char *mi - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender; - (void)draggingExited:(id < NSDraggingInfo >)sender; - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal; -- (void)FLselectMarkedText; @end @implementation FLView @@ -1937,8 +1937,7 @@ static void q_set_window_title(NSWindow *nsw, const char * name, const char *mi // Transform character palette actions to FL_PASTE events. Fl_Window *target = [(FLWindow*)[self window] getFl_Window]; Fl::handle( (in_key_event || Fl::compose_state) ? FL_KEYBOARD : FL_PASTE, target); - Fl::compose_state = 0; - [self FLselectMarkedText]; + Fl_X::compose_state(0); // for some reason, with the palette, the window does not redraw until the next mouse move or button push // sending a 'redraw()' or 'awake()' does not solve the issue! @@ -1961,32 +1960,14 @@ static void q_set_window_title(NSWindow *nsw, const char * name, const char *mi received, newSelection.location, newSelection.length, Fl::compose_state, Fl::e_length);*/ Fl_Window *target = [(FLWindow*)[self window] getFl_Window]; Fl::handle(FL_KEYBOARD, target); - Fl::compose_state = Fl::e_length; - [self FLselectMarkedText]; + Fl_X::compose_state(Fl::e_length); fl_unlock_function(); } -- (void)FLselectMarkedText -{ // set/clear marked text as selected in text widgets - Fl_Widget *widget = Fl::focus(); - if (!widget) return; - if (dynamic_cast<Fl_Input_*>(widget) != NULL) { - Fl_Input_* input = (Fl_Input_*)widget; - input->mark( input->position() - Fl::compose_state ); - } - else if (dynamic_cast<Fl_Text_Display*>(widget) != NULL) { - Fl_Text_Display* input = (Fl_Text_Display*)widget; - Fl_Text_Selection* sel = (Fl_Text_Selection*)input->buffer()->highlight_selection(); - int pos = input->insert_position(); - sel->set(pos - Fl::compose_state, pos); - } -} - - (void)unmarkText { fl_lock_function(); - Fl::compose_state = 0; - [self FLselectMarkedText]; + Fl_X::compose_state(0); fl_unlock_function(); //NSLog(@"unmarkText"); } @@ -2052,6 +2033,24 @@ static void q_set_window_title(NSWindow *nsw, const char * name, const char *mi @end +void Fl_X::compose_state(int new_val) +{ // highlight marked text in text widgets + if (Fl::compose_state == 0 && new_val == 0) return; + Fl::compose_state = new_val; + Fl_Widget *widget = Fl::focus(); + if (!widget) return; + if (dynamic_cast<Fl_Input_*>(widget) != NULL) { + if (dynamic_cast<Fl_Secret_Input*>(widget) != NULL) return; + Fl_Input_* input = (Fl_Input_*)widget; + input->mark( input->position() - Fl::compose_state ); + } + else if (dynamic_cast<Fl_Text_Display*>(widget) != NULL) { + Fl_Text_Display* input = (Fl_Text_Display*)widget; + int pos = input->insert_position(); + input->buffer()->highlight(pos - Fl::compose_state, pos); + } +} + void Fl_Window::fullscreen_x() { _set_fullscreen(); /* On OS X < 10.6, it is necessary to recreate the window. This is done diff --git a/src/Fl_compose.cxx b/src/Fl_compose.cxx index 9bda479c4..870d2dc78 100644 --- a/src/Fl_compose.cxx +++ b/src/Fl_compose.cxx @@ -84,10 +84,14 @@ int Fl::compose(int& del) { */ void Fl::compose_reset() { +#ifdef __APPLE__ + Fl_X::compose_state(0); +#else Fl::compose_state = 0; -#if !defined(WIN32) && !defined(__APPLE__) +#if !defined(WIN32) if (fl_xim_ic) XmbResetIC(fl_xim_ic); #endif +#endif } // |
