Author: manolo
Date: 2012-12-18 07:32:30 -0800 (Tue, 18 Dec 2012)
New Revision: 9765
Log:
Mac OS: completed text input support.
Modified:
branches/branch-3.0/include/fltk3/osx.h
branches/branch-3.0/src/fltk3/cocoa.mm
branches/branch-3.0/src/fltk3/compose.cxx
Modified: branches/branch-3.0/include/fltk3/osx.h
===================================================================
--- branches/branch-3.0/include/fltk3/osx.h 2012-12-18 14:54:08 UTC (rev
9764)
+++ branches/branch-3.0/include/fltk3/osx.h 2012-12-18 15:32:30 UTC (rev
9765)
@@ -145,6 +145,7 @@
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 unsigned short *compute_macKeyLookUp();
+ static void compose_state(int);
private:
static void relink(fltk3::Window*, fltk3::Window*);
bool subwindow;
Modified: branches/branch-3.0/src/fltk3/cocoa.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoa.mm 2012-12-18 14:54:08 UTC (rev
9764)
+++ branches/branch-3.0/src/fltk3/cocoa.mm 2012-12-18 15:32:30 UTC (rev
9765)
@@ -45,6 +45,7 @@
#include <fltk3/SysMenuBar.h>
#include <fltk3/Printer.h>
#include <fltk3/Input_.h>
+#include <fltk3/SecretInput.h>
#include <fltk3/TextDisplay.h>
#include <stdio.h>
#include <stdlib.h>
@@ -1653,7 +1654,6 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
- (void)draggingExited:(id < NSDraggingInfo >)sender;
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
-- (void)FLselectMarkedText;
@end
@implementation FLView
@@ -1916,8 +1916,7 @@
// Transform character palette actions to FL_PASTE events.
fltk3::Window *target = [(FLWindow*)[self window] getFl_Window];
fltk3::handle( (in_key_event || fltk3::compose_state) ? fltk3::KEYBOARD :
fltk3::PASTE, target);
- fltk3::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!
@@ -1940,31 +1939,13 @@
received, newSelection.location, newSelection.length, fltk3::compose_state,
fltk3::e_length);*/
fltk3::Window *target = [(FLWindow*)[self window] getFl_Window];
fltk3::handle(fltk3::KEYBOARD, target);
- fltk3::compose_state = fltk3::e_length;
- [self FLselectMarkedText];
+ Fl_X::compose_state(fltk3::e_length);
fl_unlock_function();
}
-- (void)FLselectMarkedText
-{ // set/clear marked text as selected in text widgets
- fltk3::Widget *widget = fltk3::focus();
- if (!widget) return;
- if (dynamic_cast<fltk3::Input_*>(widget) != NULL) {
- fltk3::Input_* input = (fltk3::Input_*)widget;
- input->mark( input->position() - fltk3::compose_state );
- }
- else if (dynamic_cast<fltk3::TextDisplay*>(widget) != NULL) {
- fltk3::TextDisplay* input = (fltk3::TextDisplay*)widget;
- fltk3::TextSelection* sel =
(fltk3::TextSelection*)input->buffer()->highlight_selection();
- int pos = input->insert_position();
- sel->set(pos - fltk3::compose_state, pos);
- }
-}
-
- (void)unmarkText {
fl_lock_function();
- fltk3::compose_state = 0;
- [self FLselectMarkedText];
+ Fl_X::compose_state(0);
fl_unlock_function();
//NSLog(@"unmarkText");
}
@@ -2030,6 +2011,25 @@
@end
+void Fl_X::compose_state(int new_val)
+{ // select marked text in text widgets
+ if (fltk3::compose_state == 0 && new_val == 0) return;
+ fltk3::compose_state = new_val;
+ fltk3::Widget *widget = fltk3::focus();
+ if (!widget) return;
+
+ fltk3::Input_* input = dynamic_cast<fltk3::Input_*>(widget);
+ fltk3::TextDisplay* text;
+ if (input) {
+ if ( ! dynamic_cast<fltk3::SecretInput*>(input) )
+ input->mark( input->position() - fltk3::compose_state );
+ }
+ else if ( (text = dynamic_cast<fltk3::TextDisplay*>(widget)) ) {
+ int pos = text->insert_position();
+ text->buffer()->select(pos - fltk3::compose_state, pos);
+ }
+}
+
void fltk3::Window::fullscreen_x() {
_set_fullscreen();
/* On OS X < 10.6, it is necessary to recreate the window. This is done
Modified: branches/branch-3.0/src/fltk3/compose.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/compose.cxx 2012-12-18 14:54:08 UTC (rev
9764)
+++ branches/branch-3.0/src/fltk3/compose.cxx 2012-12-18 15:32:30 UTC (rev
9765)
@@ -55,33 +55,28 @@
other user-interface things to allow characters to be selected.
*/
int fltk3::compose(int& del) {
- // character composition is now handled by the OS
- del = 0;
+ int condition;
#if defined(__APPLE__)
int has_text_key = fltk3::compose_state || fltk3::e_keysym <= '~' ||
fltk3::e_keysym == fltk3::IsoKey ||
- (fltk3::e_keysym >= fltk3::KPKey && fltk3::e_keysym <= fltk3::KPLastKey &&
fltk3::e_keysym != fltk3::KPEnterKey);
- if ( fltk3::e_state&(fltk3::META | fltk3::CTRL) ||
- (fltk3::e_keysym >= fltk3::ShiftLKey && fltk3::e_keysym <=
fltk3::AltRKey) || // called from flagsChanged
- !has_text_key ) {
- // this stuff is to be treated as a function key
- return 0;
- }
-#elif defined(WIN32)
- unsigned char ascii = (unsigned)e_text[0];
- if ((e_state & (fltk3::ALT | fltk3::META)) && !(ascii & 128)) return 0;
+ (fltk3::e_keysym >= fltk3::KPKey && fltk3::e_keysym <= fltk3::KPLastKey &&
fltk3::e_keysym != fltk3::KPEnterKey);
+ condition = fltk3::e_state&(fltk3::META | fltk3::CTRL) ||
+ (fltk3::e_keysym >= fltk3::ShiftLKey && fltk3::e_keysym <= fltk3::AltRKey)
|| // called from flagsChanged
+ !has_text_key ;
#else
- unsigned char ascii = (unsigned)e_text[0];
- if ((e_state & (fltk3::ALT | fltk3::META | fltk3::CTRL)) && !(ascii & 128))
return 0;
+ unsigned char ascii = (unsigned char)e_text[0];
+#if defined(WIN32)
+ condition = (e_state & (fltk3::ALT | fltk3::META)) && !(ascii & 128) ;
+#else
+ condition = (e_state & (fltk3::ALT | fltk3::META | fltk3::CTRL)) && !(ascii
& 128) ;
#endif
- if(fltk3::compose_state) {
- del = fltk3::compose_state;
+#endif
+ if (condition) { del = 0; return 0;} // this stuff is to be treated as a
function key
+ del = fltk3::compose_state;
#ifndef __APPLE__
- fltk3::compose_state = 0;
- } else {
- // Only insert non-control characters:
- if (! (ascii & ~31 && ascii!=127)) { return 0; }
+ fltk3::compose_state = 0;
+ // Only insert non-control characters:
+ if ( (!fltk3::compose_state) && ! (ascii & ~31 && ascii!=127)) { return 0; }
#endif
- }
return 1;
}
@@ -93,10 +88,14 @@
*/
void fltk3::compose_reset()
{
+#ifdef __APPLE__
+ Fl_X::compose_state(0);
+#else
fltk3::compose_state = 0;
-#if !defined(WIN32) && !defined(__APPLE__)
+#if !defined(WIN32)
if (fl_xim_ic) XmbResetIC(fl_xim_ic);
#endif
+#endif
}
//
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit