double-clicking in FileDialog skips event?

double-clicking in FileDialog skips event?
I am using an AUInotebook control whose pages contain 2 different types of panels. One is tree and the other is a Styled text control.

I have functions on the AUI that are handling the tab changing event - which rebinds various keyboard shortcuts.

So for example, the user presses CTRL+O in my app with the STC tab active and it tries to open a script. Often the FileDialog is positioned on top of my other tab page (with the TreeCtrl in it). If I single-click on a file and press the “open” button, everything works fine. If I double-click on the file in the FileDialog (to open that file without having to move to the “open” button) the file dialog disappears and the file is opened as expected. However, the tab that was beneath the FileDialog is now selected.

So now that the TreeCtrl tab has been selected, the keyboard shortcuts and menu bindings have been changed - which causes some rather unexpected behavior for the user.

In short, is this a bug where the Double-click seems to get propogated to the panel/frame beneath the modal FileDialog after a double-click? Or more importatly, is there any way I can get around this (maybe by creating a new dialog that inherits from FileDialog?) and prevent that double-click from selecting the AUINotebook tab beneath it?

Thanks,

Andrew

When you get a file from the modal file open dialog, perform a
wx.CallAfter(stc.SetFocus) . That should redirect the focus back to the
STC.

- Josiah

···

"Pangborn, Andrew \(ext. 324\)" <axp@qvii.com> wrote:

I am using an AUInotebook control whose pages contain 2 different
types of panels. One is tree and the other is a Styled text control.

I have functions on the AUI that are handling the tab changing event
- which rebinds various keyboard shortcuts.

So for example, the user presses CTRL+O in my app with the STC tab
active and it tries to open a script. Often the FileDialog is
positioned on top of my other tab page (with the TreeCtrl in it). If
I single-click on a file and press the "open" button, everything works
fine. If I double-click on the file in the FileDialog (to open that
file without having to move to the "open" button) the file dialog
disappears and the file is opened as expected. However, the tab that
was beneath the FileDialog is now selected.

So now that the TreeCtrl tab has been selected, the keyboard shortcuts
and menu bindings have been changed - which causes some rather
unexpected behavior for the user.

Seemed like a great idea. I added code that would change the AUINotebook selection with wx.CallAfter since setting the focus on my STC didnt seem to invoke the tab switching. However the notebook is still selecting the tab beneath the FileDialog after the CallAfter statement...

    if dlg.ShowModal() == wx.ID_OK:
        # Code that handles opening of the file.....
        def foo():
            self.parent.Selection = self.parent.GetPageIndex(self)
                
        wx.CallAfter(foo)

To make it even stranger...every once in awhile it does work - so it doesn't seem like the events are being generated in a consistent manner (maybe due to the speed/timing of the mouse click?)

Forgot to mention this before: wxPython 2.8.1.1 & Python 2.5 on Windows XP

Andrew

···

-----Original Message-----
From: Josiah Carlson [mailto:jcarlson@uci.edu]
Sent: Tuesday, February 13, 2007 2:17 PM
To: Pangborn, Andrew (ext. 324); wxPython-users (E-mail)
Subject: Re: [wxPython-users] double-clicking in FileDialog skips event?

When you get a file from the modal file open dialog, perform a
wx.CallAfter(stc.SetFocus) . That should redirect the focus back to the
STC.

I found out a little bit more with some testing.

If I double-click on the little icon next to the filename in the FileDialog, everything works fine. If I double click on the text in the filename, then I get the problem where the AUINotebook beneath is being selected. This behavior albeit confusing to me, seems to be consistent.

Not sure if that helps explain anything, or just makes it more confusing.

Thanks again,
Andrew

···

-----Original Message-----
From: Pangborn, Andrew (ext. 324) [mailto:axp@qvii.com]
Sent: Tuesday, February 13, 2007 2:58 PM
To: wxPython-users@lists.wxwidgets.org
Subject: RE: [wxPython-users] double-clicking in FileDialog skips event?

To make it even stranger...every once in awhile it does work - so it doesn't seem like the events are being generated in a consistent manner (maybe due to the speed/timing of the mouse click?)

Seemed like a great idea. I added code that would change the
AUINotebook selection with wx.CallAfter since setting the focus on my
STC didnt seem to invoke the tab switching. However the notebook is
still selecting the tab beneath the FileDialog after the CallAfter
statement...

    if dlg.ShowModal() == wx.ID_OK:
        # Code that handles opening of the file.....
        def foo():
            self.parent.Selection = self.parent.GetPageIndex(self)

              self.SetFocus()

        wx.CallAfter(foo)

Have you tried to toss in the above .SetFocus() call?

- Josiah

···

"Pangborn, Andrew \(ext. 324\)" <axp@qvii.com> wrote:

Pangborn, Andrew (ext. 324) wrote:

In short, is this a bug where the Double-click seems to get propogated to the panel/frame beneath the modal FileDialog after a double-click? Or more importatly, is there any way I can get around this (maybe by creating a new dialog that inherits from FileDialog?) and prevent that double-click from selecting the AUINotebook tab beneath it?

Basically, what's happening is that the dialog is closing itself on the down-stroke of the second part of the double click, leaving the up-stroke part of the event to be caught by whatever window is underneath it. I usually work around this by setting a flag or something that causes my underlying window to ignore that event, but where this is a AUINotebook and not under your control I'm not sure what to suggest. Maybe temporarily connecting your own event handler so you can ignore that event, and then disconnecting it...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

We have narrowed it down a litte. We have CustomTreeCtrl's in the tabs, and the AuiNotebook's EVT_TAB_CHANGED is getting called. However this only happens when the file that was double clicked is over a tree item. For example if I drag the open dialog down to below the last item of the tree and double click, everything is fine. But when the file double clicked from the dialog is on or next to a tree item, it happens. We have print statements everywhere we are manually changing the tab selection and none of those are firing. We also have print statements in all our event handlers in tree with items and clicks, but none of those are doing it either. This is confusing!

This probably is either something really dumb we are doing, or some incredibly complex buried issue with an AuiNotebook or CustomTreeCtrl!

Does this trigger any more memories or ideas you might have? I can try to duplicate this in a little example if necessary but it might not be so easy.

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Wednesday, February 14, 2007 3:08 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] double-clicking in FileDialog skips event?

Pangborn, Andrew (ext. 324) wrote:

In short, is this a bug where the Double-click seems to get propogated
to the panel/frame beneath the modal FileDialog after a double-click? Or
more importatly, is there any way I can get around this (maybe by
creating a new dialog that inherits from FileDialog?) and prevent that
double-click from selecting the AUINotebook tab beneath it?

Basically, what's happening is that the dialog is closing itself on the
down-stroke of the second part of the double click, leaving the
up-stroke part of the event to be caught by whatever window is
underneath it. I usually work around this by setting a flag or
something that causes my underlying window to ignore that event, but
where this is a AUINotebook and not under your control I'm not sure what
to suggest. Maybe temporarily connecting your own event handler so you
can ignore that event, and then disconnecting it...

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Well, it wasn't so hard to make a small example. Luckily (I guess?) it reproduces our problem. You will have to drag the second tab over to the right, like in the attached picture.

The second tab is selected. Clicking Open from the toolbar, and double clicking on qvi.pth, which is next to a tree item, will cause tab 1 to be selected. However double clicking LICENSE.txt will not cause the issue since it is below tree items.

This is confusing to me as, as I recall, tabs don't do any selecting of themselves when focus is made to their children. We had to implement that ourselves. So what is happening here? What kind of patch can we make to this example?

Thanks so much for taking the time to look at this and help us out!

- Mike

test.py (1.28 KB)

···

-----Original Message-----
From: Rooney, Mike (ext. 324) [mailto:mxr@qvii.com]
Sent: Wednesday, February 14, 2007 9:58 AM
To: wxPython-users@lists.wxwidgets.org
Subject: RE: [wxPython-users] double-clicking in FileDialog skips event?

We have narrowed it down a litte. We have CustomTreeCtrl's in the tabs, and the AuiNotebook's EVT_TAB_CHANGED is getting called. However this only happens when the file that was double clicked is over a tree item. For example if I drag the open dialog down to below the last item of the tree and double click, everything is fine. But when the file double clicked from the dialog is on or next to a tree item, it happens. We have print statements everywhere we are manually changing the tab selection and none of those are firing. We also have print statements in all our event handlers in tree with items and clicks, but none of those are doing it either. This is confusing!

This probably is either something really dumb we are doing, or some incredibly complex buried issue with an AuiNotebook or CustomTreeCtrl!

Does this trigger any more memories or ideas you might have? I can try to duplicate this in a little example if necessary but it might not be so easy.

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Wednesday, February 14, 2007 3:08 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] double-clicking in FileDialog skips event?

Pangborn, Andrew (ext. 324) wrote:

In short, is this a bug where the Double-click seems to get propogated
to the panel/frame beneath the modal FileDialog after a double-click? Or
more importatly, is there any way I can get around this (maybe by
creating a new dialog that inherits from FileDialog?) and prevent that
double-click from selecting the AUINotebook tab beneath it?

Basically, what's happening is that the dialog is closing itself on the
down-stroke of the second part of the double click, leaving the
up-stroke part of the event to be caught by whatever window is
underneath it. I usually work around this by setting a flag or
something that causes my underlying window to ignore that event, but
where this is a AUINotebook and not under your control I'm not sure what
to suggest. Maybe temporarily connecting your own event handler so you
can ignore that event, and then disconnecting it...

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Rooney, Mike (ext. 324) wrote:

Well, it wasn't so hard to make a small example. Luckily (I guess?)
it reproduces our problem. You will have to drag the second tab over
to the right, like in the attached picture.

The second tab is selected. Clicking Open from the toolbar, and
double clicking on qvi.pth, which is next to a tree item, will cause
tab 1 to be selected. However double clicking LICENSE.txt will not
cause the issue since it is below tree items.

This is confusing to me as, as I recall, tabs don't do any selecting
of themselves when focus is made to their children. We had to
implement that ourselves. So what is happening here? What kind of
patch can we make to this example?

Like I said, it is happening because the left over left-up event is being processed by the widget under the mouse, the custom treectrl in this case. You can see this by adding something like this in the OnMouse method in customtreectrl.py:

         if event.ButtonUp():
             print 'up'

I've attached an example of one way to work around this. Basically it temporarily pushes a new handler onto the event handler stack of the treectrls, and the new handler just ignores all mouse events.

dclicktest.py (1.79 KB)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!