Mercurial > octave-nkf
diff libgui/graphics/Figure.cc @ 20629: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 | d0f886a030b7 |
children | 99eb26310cb3 |
line wrap: on
line diff
--- a/libgui/graphics/Figure.cc Fri Oct 09 16:25:27 2015 +0200 +++ b/libgui/graphics/Figure.cc Sat Oct 10 12:21:37 2015 +0200 @@ -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