Key event and PopupTransientWindow in ScrolledWindow

Hi,

problem: Key event and PopupTransientWindow in ScrolledWindow

In a ScrolledWindow I use mouse-left-down and shift-mouse-left-down to
select things. This works fine. Next I added a PopupTransientWindow
(PTW) to obtain position dependent information via mouse-right-down.
This works fine too.

However, when the first thing I do is pop up the PTW by mouse-right-down
and close the PTW by a mouse click, later key events are not handled
anymore. When the first thing I do is anything but mouse-right-down, key
events are handled even after popping up the PTW.

When I replace the PTW by a MiniFrame there is no such behaviour (key
events are handled). But I happen to like the no-nonsense look of the
PTW. Using a MiniFrame would be more or less ok if I only knew how to
change the background colour of the title bar (always staying on top is
something I should be able to figure out myself).

I also noticed that ScrolledWindow initially does not seem to react to
key events, it only does so after a mouse event?

Am I doing something wrong? Any help will be greatly appreciated. I'll
attach an example.

Regards, Igor Hoveijn

Versions:

python 2.5.2
wxpython 2.8.7.1
debian linux 2.6.26-2-686

hvnpopup.py (1.9 KB)

Hi,

problem: Key event and PopupTransientWindow in ScrolledWindow

In a ScrolledWindow I use mouse-left-down and shift-mouse-left-down to
select things. This works fine. Next I added a PopupTransientWindow
(PTW) to obtain position dependent information via mouse-right-down.
This works fine too.

BTW, you don't need to catch the key events just to track the state of the shift key. You can get that from the mouse event with event.ShiftDown()

However, when the first thing I do is pop up the PTW by mouse-right-down
and close the PTW by a mouse click, later key events are not handled
anymore. When the first thing I do is anything but mouse-right-down, key
events are handled even after popping up the PTW.

When I replace the PTW by a MiniFrame there is no such behaviour (key
events are handled). But I happen to like the no-nonsense look of the
PTW. Using a MiniFrame would be more or less ok if I only knew how to
change the background colour of the title bar (always staying on top is
something I should be able to figure out myself).

I also noticed that ScrolledWindow initially does not seem to react to
key events, it only does so after a mouse event?

It doesn't initially get the focus like it will on other platforms. You can call SetFocus in your code to get it there at the beginning. After adding that to MyScroll.__init__ then subsequent key events are working for me.

···

On 1/24/11 1:27 PM, I. Hoveijn wrote:

--
Robin Dunn
Software Craftsman

Hi Robin,

Thanks very mich for your help. I didn't know about the existence of
event.ShiftDown(), much better of course than tracking the shift state
myself. I'll use the SetFocus and I readily believe it will work. (Still
a lot to learn about wxPython...)

Regards, Igor Hoveijn

···

On Mon, 2011-01-24 at 13:46 -0800, Robin Dunn wrote:

On 1/24/11 1:27 PM, I. Hoveijn wrote:
> Hi,
>
> problem: Key event and PopupTransientWindow in ScrolledWindow
>
> In a ScrolledWindow I use mouse-left-down and shift-mouse-left-down to
> select things. This works fine. Next I added a PopupTransientWindow
> (PTW) to obtain position dependent information via mouse-right-down.
> This works fine too.

BTW, you don't need to catch the key events just to track the state of
the shift key. You can get that from the mouse event with event.ShiftDown()

>
> However, when the first thing I do is pop up the PTW by mouse-right-down
> and close the PTW by a mouse click, later key events are not handled
> anymore. When the first thing I do is anything but mouse-right-down, key
> events are handled even after popping up the PTW.
>
> When I replace the PTW by a MiniFrame there is no such behaviour (key
> events are handled). But I happen to like the no-nonsense look of the
> PTW. Using a MiniFrame would be more or less ok if I only knew how to
> change the background colour of the title bar (always staying on top is
> something I should be able to figure out myself).
>
> I also noticed that ScrolledWindow initially does not seem to react to
> key events, it only does so after a mouse event?

It doesn't initially get the focus like it will on other platforms. You
can call SetFocus in your code to get it there at the beginning. After
adding that to MyScroll.__init__ then subsequent key events are working
for me.