# HG changeset patch # User Rik # Date 1429803529 25200 # Node ID 144498565de97c557e89224d0fb6daf57786f1fc # Parent 094ae7cc2d1dd14a3d35efed1fbca5bc66abb989 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. diff -r 094ae7cc2d1d -r 144498565de9 libinterp/dldfcn/__init_fltk__.cc --- 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':