[wxMac 2.8, mac os 10.4.8] controlling focus between frames

bowser alessandro.denardi at gmail.com
Wed Mar 14 14:22:07 PDT 2007


Hello,
I'm porting a project from windows, where I implemented every
feature that I needed, to mac os x ( using wxMac 2.8). In the
wx discussion forum I couldn't solve my problem so I hope I'll be
luckier here. I think that it is related to the Mac's policy about the
focus. I'm not sure about this, since I'm new to this platform.

I'm implementing a kind of tooltip frame. I didn't use the built-in
class beacause I want an interactive text control inside.
In detailed, the tooltip (a class deriving wxFrame) can appear
when the user MouseDown on a control in the main frame.
The user then can drag the mouse to interact with the control.
Finally he should be able to MouseUp on the tooltip, meaning
that the tooltip should receive the event.
In other words I need to interact with both frames, without
clicking on them first, to set the focus.

Initially I couldn't avoid the tooltip from steeling the focus to its
parent; it happened every time I Show() or Raise() the tooltip.
SetFocus() on the parent had no effect.
I found that the only way to prevent the focus steeling is by
setting both flags: wxFRAME_TOOL_WINDOW and wxCAPTION.
Unfortunately a small bar (the caption) appears in it, and tooltips
don't have any.

The second problem (smaller, and I eventually could pass over
it...) is that the tooltip (implemented with the flags above) can't
get the EVT_MOUSE_UP (when the relative EVT_MOUSE_DOWN,
launched just before is the one handled by the main frame - see
the tooltip's description above).

Notes:
The problems are there, no matter if I set and unset the flags
wxSTAY_ON_TOP and wxFLOAT_ON_PARENT, that I need for
the tooltip.
A small and complete program that demonstrate the problem can
be found here: http://paste.videolan.org/1536

Thank you in advance.

Alessandro




More information about the wx-users mailing list