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
This commit is contained in:
parent
3eb27ccf3e
commit
46abc078b4
1
FL/mac.H
1
FL/mac.H
@ -131,6 +131,7 @@ public:
|
||||
static CGContextRef none_cursor_image(void);
|
||||
static void *get_carbon_function(const char *name);
|
||||
static void screen_work_area(int &X, int &Y, int &W, int &H, int n); // compute work area of a given screen
|
||||
static void compose_state(int);
|
||||
private:
|
||||
static void relink(Fl_Window*, Fl_Window*);
|
||||
bool subwindow;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user