|
|
Hi, is it possible to add a cancel event on FL_Text_Editor?
I want on enter key press to do a method instead a new line.
I know how to capture enter key press, I just want to cancel
the new line.
To prevent the Enter key from inserting a new line into the
editor,
just return from your subclass's handle() method when the
FL_ENTER
key goes up and down.
That will block the event from ever being seen by the
Fl_Text_Editor,
preventing it from being 'typed'.
And of course you can call your method instead when that
happens.
Just be sure the event doesn't get to the text editor, both
the "key up"
and the "key down" events.
So basically (code not tested, may contain typos, an exercise
for the reader to solve):
void YourSubclass::handle(int e) {
if ( e == FL_KEYUP || e == FL_KEYDOWN )
if ( Fl::event_key() == FL_Enter || FL_KP_Enter )
{
// Enter key was hit or released
// Do what you want here, but make
sure you DONT
// let the event be seen by
Fl_Text_Editor::handle().
return 1; // return, indicating
the event was handled by you
}
}
// ..possibly other logic here..
return Fl_Text_Editor::handle(e); // let all other
events be handle()ed by the text editor
}
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/c96d7420-6757-446e-5b34-cc8bff3f5ee8%40seriss.com.
[ Direct Link to Message ] | |
|
| |