So I've been playing with the menus code lately - hopefully I'll have something concrete to show soon but in the meantime a problem. We need to update the function of menu items and their enabled/disabled state depending on where the focus is (and things like whether there is selected text). For example when focused on a text box Edit - Copy should copy the text selected in that box. The problem is I'm not quite sure how to do this in a sane way. It's pretty easy to connect the appropriate slots to actions when particular widgets get focus by implementing the focusInEvent method. The problem is disconnecting things ar the right time. focusOutEvent is no good because widgets loose focus when a menu is activated. It might be possible to just have the focusInEvent disconnect any slots that are already attached but that seems suboptimal (you might want a situation where subwidgets override some, but not all, behaviors of their parents).

Am I making any sense? Does anyone have any ideas?

--
"But if science you say still sounds too deep,
Just do what Beaker does, just shrug and 'Meep!'"

-- Dr. Bunsen Honeydew & Beaker of Muppet Labs


Répondre à