From: The D. <the...@bl...> - 2005-07-22 10:35:04
|
Hi John, I have an answer, of sorts, having made FindToolForPosition() work... TBAR:ConnectEvent(-1,wx.wxEVT_LEFT_UP, function(EV) ID=TBAR:FindToolForPosition(0,1):GetId() if (EV:ControlDown()) then DoThings(ID) end EV:Skip() end ) This will detect the first tool, but is no better than manually specifying the ID. I'd also have to test for the presence of the tool before trying to GetId(), or there would be error. That's easy but what I really want is TBAR:FindToolForPosition(EV:GetPosition()). That would allow a single handler and a single function called by it, to handle any tool, and any state for Ctrl or Shift or Alt keys while clicking it with either mouse button. The only thing stopping me from getting at this wonderful power is the mind-numbingly annoying incompatibility in the way co-ordinates are handled. Surely it's not too much to expect that GetPosition() can return co-ordinates in a form that FindToolForPosition() can use?! I guess it is though. Is there a way to convert? It's things like this that keep me slow and asking confusing questions. The trouble with wxWidgets, (or wxLua, I'm not quite sure which) is that unlike Lua itself, so much is done with specific behaviours that don't seem to talk well to each other, except via black boxes whose behaviour alone is all I have to go on to understand them. In Lua, the emphasis is on a simple versatile system that can be adapted to many ways of working. This is partway possible with wxLua too, but the most versatile forms seem to involve catching mouse events, but I keep being thwarted with proplems like lack of propagation, or mismatches in co-ordinate handling methods, or problems getting ID's for things, of finding those things to be userdata and finding no way to know what exactly that userdata is. To illustrate that last point, I can do this: ID=TBAR:FindToolForPosition(0,1):GetId() Which seems to imply that TBAR:FindToolForPosition(0,1) will point to the actual tool. If it did, I could do this: X=TBAR:FindToolForPosition(0,1) X:ConnectEvent(-1,wx.wxEVT_LEFT_UP, function(EV) stuff... end ) This won't go. ConnectEvent is invalid in this case. Whatever X is, it's not the tool! And I have no way to know what it is. |