Mercurial > hg > octave-nkf
changeset 20805:46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
* Canvas.cc (Canvas::canvasMouseMoveEvent): decide here to update the currentpoint and run "windowbuttonmotionfcn" if the latter is not empty
* Canvas.h: remove unused "enableCurrentPointUpdates" method and "m_updateCurrentPoint" attribute
* Figure.h: declare a new private method "enableMouseTracking"
* Figure.cc (Figure::Figure): use "enableMouseTracking" instead of "update" on "windowbuttonmotionfcn".
* Figure.cc (Figure::update): mouse tracking is now enabled unconditionally so remove unused case "windowbuttonmotionfcn".
*Figure.cc(Figure::eventNotifyAfter): enable mouse tracking on new children widgets.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sat, 10 Oct 2015 12:21:37 +0200 |
parents | 3af34e1ef330 |
children | 99eb26310cb3 |
files | libgui/graphics/Canvas.cc libgui/graphics/Canvas.h libgui/graphics/Figure.cc libgui/graphics/Figure.h |
diffstat | 4 files changed, 26 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc +++ b/libgui/graphics/Canvas.cc @@ -507,7 +507,7 @@ break; } } - else if (m_mouseMode == NoMode && m_updateCurrentPoint) + else if (m_mouseMode == NoMode) { graphics_object obj = gh_manager::get_object (m_handle); @@ -515,9 +515,13 @@ { graphics_object figObj (obj.get_ancestor ("figure")); - updateCurrentPoint (figObj, obj, event); - gh_manager::post_callback (figObj.get_handle (), - "windowbuttonmotionfcn"); + if (figObj.valid_object () && + ! figObj.get ("windowbuttonmotionfcn").is_empty ()) + { + updateCurrentPoint (figObj, obj, event); + gh_manager::post_callback (figObj.get_handle (), + "windowbuttonmotionfcn"); + } } }
--- a/libgui/graphics/Canvas.h +++ b/libgui/graphics/Canvas.h @@ -70,7 +70,6 @@ virtual void toggleAxes (const graphics_handle& handle) = 0; virtual void toggleGrid (const graphics_handle& handle) = 0; virtual void autoAxes (const graphics_handle& handle) = 0; - void enableCurrentPointUpdates (bool on) { m_updateCurrentPoint = on; } protected: virtual void draw (const graphics_handle& handle) = 0; @@ -86,8 +85,7 @@ m_mouseMode (NoMode), m_clickMode (false), m_eventMask (0), - m_rectMode (false), - m_updateCurrentPoint (false) + m_rectMode (false) { } void canvasToggleAxes (const graphics_handle& handle); @@ -122,7 +120,6 @@ graphics_handle m_mouseAxes; int m_eventMask; bool m_rectMode; - bool m_updateCurrentPoint; }; }; // namespace QtHandles
--- a/libgui/graphics/Figure.cc +++ b/libgui/graphics/Figure.cc @@ -132,11 +132,6 @@ figure::properties& fp = properties<figure> (); - // Enable mouse tracking - m_container->setMouseTracking (true); - foreach (QWidget* w, m_container->findChildren<QWidget*> ()) - { w->setMouseTracking (true); } - // Status bar m_statusBar = win->statusBar (); int boffset = 0; @@ -168,6 +163,9 @@ win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset)); + // Enable mouse tracking unconditionally + enableMouseTracking (); + // When this constructor gets called all properties are already // set, even non default. We force "update" here to get things right. @@ -179,10 +177,6 @@ update (figure::properties::ID_KEYPRESSFCN); update (figure::properties::ID_KEYRELEASEFCN); - // Decide if the "currentpoint" is updated on mouse movements and - // if the windowbuttonmotionfcn is executed - update (figure::properties::ID_WINDOWBUTTONMOTIONFCN); - // Visibility update (figure::properties::ID_VISIBLE); @@ -485,14 +479,6 @@ m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); break; - case figure::properties::ID_WINDOWBUTTONMOTIONFCN: - { - bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty (); - - m_container->canvas (m_handle)->enableCurrentPointUpdates (hasCallback); - } - break; - default: break; } @@ -733,6 +719,8 @@ { gh_manager::auto_lock lock; update (figure::properties::ID_TOOLBAR); + + enableMouseTracking (); } default: @@ -981,4 +969,14 @@ canvas->autoAxes (m_handle); } +void +Figure::enableMouseTracking (void) +{ + // Enable mouse tracking on every widgets + m_container->setMouseTracking (true); + m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true); + foreach (QWidget* w, m_container->findChildren<QWidget*> ()) + { w->setMouseTracking (true); } +} + }; // namespace QtHandles
--- a/libgui/graphics/Figure.h +++ b/libgui/graphics/Figure.h @@ -113,6 +113,8 @@ void save_figure_callback (const std::string& file); void copy_figure_callback (const std::string& format); + void enableMouseTracking (void); + private slots: void setMouseMode (MouseMode mode); void fileSaveFigure (bool prompt = false);