Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
20628:3af34e1ef330 | 20629:46edfbd31ad7 |
---|---|
130 m_container = new Container (win); | 130 m_container = new Container (win); |
131 win->setCentralWidget (m_container); | 131 win->setCentralWidget (m_container); |
132 | 132 |
133 figure::properties& fp = properties<figure> (); | 133 figure::properties& fp = properties<figure> (); |
134 | 134 |
135 // Enable mouse tracking | |
136 m_container->setMouseTracking (true); | |
137 foreach (QWidget* w, m_container->findChildren<QWidget*> ()) | |
138 { w->setMouseTracking (true); } | |
139 | |
140 // Status bar | 135 // Status bar |
141 m_statusBar = win->statusBar (); | 136 m_statusBar = win->statusBar (); |
142 int boffset = 0; | 137 int boffset = 0; |
143 | 138 |
144 // Toolbar and menubar | 139 // Toolbar and menubar |
166 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); | 161 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); |
167 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); | 162 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); |
168 | 163 |
169 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset)); | 164 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset)); |
170 | 165 |
166 // Enable mouse tracking unconditionally | |
167 enableMouseTracking (); | |
168 | |
171 // When this constructor gets called all properties are already | 169 // When this constructor gets called all properties are already |
172 // set, even non default. We force "update" here to get things right. | 170 // set, even non default. We force "update" here to get things right. |
173 | 171 |
174 // Figure title | 172 // Figure title |
175 update (figure::properties::ID_NUMBERTITLE); | 173 update (figure::properties::ID_NUMBERTITLE); |
176 | 174 |
177 // Decide what keyboard events we listen to | 175 // Decide what keyboard events we listen to |
178 m_container->canvas (m_handle)->setEventMask (0); | 176 m_container->canvas (m_handle)->setEventMask (0); |
179 update (figure::properties::ID_KEYPRESSFCN); | 177 update (figure::properties::ID_KEYPRESSFCN); |
180 update (figure::properties::ID_KEYRELEASEFCN); | 178 update (figure::properties::ID_KEYRELEASEFCN); |
181 | |
182 // Decide if the "currentpoint" is updated on mouse movements and | |
183 // if the windowbuttonmotionfcn is executed | |
184 update (figure::properties::ID_WINDOWBUTTONMOTIONFCN); | |
185 | 179 |
186 // Visibility | 180 // Visibility |
187 update (figure::properties::ID_VISIBLE); | 181 update (figure::properties::ID_VISIBLE); |
188 | 182 |
189 | 183 |
483 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease); | 477 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease); |
484 else | 478 else |
485 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); | 479 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); |
486 break; | 480 break; |
487 | 481 |
488 case figure::properties::ID_WINDOWBUTTONMOTIONFCN: | |
489 { | |
490 bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty (); | |
491 | |
492 m_container->canvas (m_handle)->enableCurrentPointUpdates (hasCallback); | |
493 } | |
494 break; | |
495 | |
496 default: | 482 default: |
497 break; | 483 break; |
498 } | 484 } |
499 | 485 |
500 m_blockUpdates = false; | 486 m_blockUpdates = false; |
731 if (dynamic_cast<QChildEvent*> (xevent)->child | 717 if (dynamic_cast<QChildEvent*> (xevent)->child |
732 ()->isWidgetType()) | 718 ()->isWidgetType()) |
733 { | 719 { |
734 gh_manager::auto_lock lock; | 720 gh_manager::auto_lock lock; |
735 update (figure::properties::ID_TOOLBAR); | 721 update (figure::properties::ID_TOOLBAR); |
722 | |
723 enableMouseTracking (); | |
736 } | 724 } |
737 | 725 |
738 default: | 726 default: |
739 break; | 727 break; |
740 } | 728 } |
979 | 967 |
980 if (canvas) | 968 if (canvas) |
981 canvas->autoAxes (m_handle); | 969 canvas->autoAxes (m_handle); |
982 } | 970 } |
983 | 971 |
972 void | |
973 Figure::enableMouseTracking (void) | |
974 { | |
975 // Enable mouse tracking on every widgets | |
976 m_container->setMouseTracking (true); | |
977 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true); | |
978 foreach (QWidget* w, m_container->findChildren<QWidget*> ()) | |
979 { w->setMouseTracking (true); } | |
980 } | |
981 | |
984 }; // namespace QtHandles | 982 }; // namespace QtHandles |