Dear all,
I have a wxPanel that contains a few child controls, like a static bitmap and a static label. I would like to register a wxEVT_LEFT_DCLICK on the panel to be notified when the user double-clicks *anywhere* in that panel, but apparently wxPanel fires wxEVT_LEFT_DCLICK only when it's empty. When it contains child controls, it looks like I have to register a handler for each control separately, and what's worse, some control types don't even fire the event (like the static label).
Is there a way to be notified of a double-click anywhere in a wxPanel, regardless of the child controls it contains?
How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
-
- Experienced Solver
- Posts: 56
- Joined: Fri Oct 12, 2018 6:12 pm
- Location: Amsterdam, the Netherlands
Re: How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
A button and other controls fire an event of type wxCommandEvent. If that event is not handled (you don't have a handler for it, or your handler calls event.Skip()) then it's propagated to the parent of the button.
You may think that having a handler in the panel it will called for any action on its children. But that's not true. Only events of type wxCommandEvent are propagated. This is not the case for wxKeyEvent.
You can simply use a key-event handle for every child of the panel.
You may think that having a handler in the panel it will called for any action on its children. But that's not true. Only events of type wxCommandEvent are propagated. This is not the case for wxKeyEvent.
You can simply use a key-event handle for every child of the panel.
Strange. I remember an old bug for this case, which was fixed some time ago. Do you use a recent wx version?some control types don't even fire the event (like the static label)
Re: How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
Manolo,
Its not a key event - its a mouse event.
To OP;
As Manolo said, only command events are propagated upwards and mouse events are not command ones.
You can register the mouse events for every single control on the panel and call event.Skip(), but if you have many controls, which have their own mouse handling it will be a disaster.
What is the idea behind this functionality?
Thank you.
Its not a key event - its a mouse event.
To OP;
As Manolo said, only command events are propagated upwards and mouse events are not command ones.
You can register the mouse events for every single control on the panel and call event.Skip(), but if you have many controls, which have their own mouse handling it will be a disaster.
What is the idea behind this functionality?
Thank you.
Re: How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
Ooops! You're right.Its not a key event - its a mouse event.
-
- Experienced Solver
- Posts: 56
- Joined: Fri Oct 12, 2018 6:12 pm
- Location: Amsterdam, the Netherlands
Re: How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
Manolo, you are absolutely right - my mistake, the static label does indeed fire wxEVT_LEFT_DCLICK, so I can definitely register for the event on both controls.
ONEEYEMAN, I'm writing a dialog showing a sort of preview or thumbnail for a number of files (of a custom type) in a directory, somewhat similar to MSW's explorer window in grid mode. Previews for each file are laid out in a grid-like fashion, and each tile consists of a few items like an image and one or more labels. The user may double-click on an individual tile to communicate that they want to load that file.
You are right, having to register for each control is a bit cumbersome, but I can't think of another way. I had a look at wxGrid but it seems to me I can only customize the content of each tile by going down the raw DC paint route, and that seems a bit overkill for my purpose. Any better ideas?
ONEEYEMAN, I'm writing a dialog showing a sort of preview or thumbnail for a number of files (of a custom type) in a directory, somewhat similar to MSW's explorer window in grid mode. Previews for each file are laid out in a grid-like fashion, and each tile consists of a few items like an image and one or more labels. The user may double-click on an individual tile to communicate that they want to load that file.
You are right, having to register for each control is a bit cumbersome, but I can't think of another way. I had a look at wxGrid but it seems to me I can only customize the content of each tile by going down the raw DC paint route, and that seems a bit overkill for my purpose. Any better ideas?
Re: How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
The only other solution i could think of would be to render everything (bitmap and labels / description) into one bitmap and then display only one wxStaticBitmap.
Use the source, Luke!
Re: How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
Hi,
Or maybe use wxBitmapButton, which can be easier to manage.
Thank you.
Or maybe use wxBitmapButton, which can be easier to manage.
Thank you.
-
- Experienced Solver
- Posts: 56
- Joined: Fri Oct 12, 2018 6:12 pm
- Location: Amsterdam, the Netherlands
Re: How can I catch wxEVT_LEFT_DCLICK on a wxPanel?
Yeah exactly, rendering everything to a bitmap is what I was trying to avoid, but may be if I can use it in a BitmapButton it's not that bad...thanks.