Mercurial > octave-antonio
changeset 20118:144498565de9
Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
* __init_fltk__.cc (handle): Update currentpoint property if a keypressfcn
callback (like that used by ginput) exists.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 23 Apr 2015 08:38:49 -0700 |
parents | 094ae7cc2d1d |
children | f46f6d906654 |
files | libinterp/dldfcn/__init_fltk__.cc |
diffstat | 1 files changed, 24 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__init_fltk__.cc Thu Apr 23 12:48:37 2015 +0100 +++ b/libinterp/dldfcn/__init_fltk__.cc Thu Apr 23 08:38:49 2015 -0700 @@ -1427,14 +1427,34 @@ int e_key = Fl::event_key (); const char *e_text = Fl::event_text (); int e_state = Fl::event_state (); - octave_scalar_map evt = - format_key_event (e_key, e_text, e_state); + octave_scalar_map evt = format_key_event (e_key, e_text, e_state); fp.set_currentcharacter (std::string (e_text)); - if (fp.get_keypressfcn ().is_defined () + + if (! fp.get_keypressfcn ().is_empty () && (evt.contents ("Key").length () > 0)) - fp.execute_keypressfcn (evt); + { + // Update CurrentPoint before callback + if (Fl::event_inside (canvas)) + { + pos_x = Fl::event_x (); + pos_y = Fl::event_y () - menu_dy (); + + set_currentpoint (pos_x, pos_y); + + gh = pixel2axes_or_ca (pos_x, pos_y); + if (gh.ok ()) + { + ax_obj = gh_manager::get_object (gh); + set_axes_currentpoint (ax_obj, pos_x, pos_y); + } + } + + fp.execute_keypressfcn (evt); + } + + // Handle special keys used in toolbar switch (e_key) { case 'a':