Label MouseDown Event not working on Subwindow

I have been struggling with a strange phenomena with the MouseDown event on labels on a secondary window.

On the primary window (my main application dialog) everything is fine. If the user presses the label, the MouseDown event fires.

If i open a secondary window from the primary one with a label which is attached to the MouseDown event, nothing happens upon a mouse press!

I have tried different window types, no difference.

MouseEnter and MouseExit work fine.

On all other controls (i didn’t try all of course but the usual suspects), MouseDown fires reliably as expected.

I did find a post last week from 2018 or so where a similar phenomena with secondary windows was described but i can’t find it anymore and quite frankly i do not want to believe that this could still be an issue …!

Now sometimes i can get it to work after i press some other control first which fires an event but that is not really an option and it certainly is not a solution.

Oh the application is a desktop app and it happens on Windows and Mac alike.

HELP!?!

Can you provide a sample project? That will make it easier for someone to help.
You can zip it and upload to your post.

1 Like

On Windows if you have a modal window and open a non-modal window (type Document) then the controls in the non-modal window don’t react.

Maybe you have a similar case?

modalwindow.xojo_binary_project.zip (5.4 KB)

1 Like

@AlbertoD: Sorry about the late response, i was pulled off into another project …

I haven’t had the chance yet to build a sample project and it seems that StefanA already has one demonstrating the problem …

@StefanA: Your example is even more restricted than my project – at least i have control over PushButtons!

But thanks for the hint with Modal / NonModal. As soon as i change the window type or the call to non-modal, everything seems to work fine. The subwindow does need to be modal though since my main window is waiting for a response …

What do i need to change to make this work?

Is the main window modal as well?

The main window is type document and using the Show command.

I have tried a couple of combinations of modeless / modal window types plus Show / ShowModal now, but either the subwindow winds up not being modal or the events don’t fire …

I had a similar issue some years ago calling a Modal subwindow from a listbox doubleclick event. See issues #46701

A workround was to use a Timer.CallLater statement in the doublclick event to call a method with the subwindow modal statement.

See the attached example project for a demonstration of various controls with and without the workround code.

ModalWindowMouseDownWorkRound.zip (9.8 KB)

Thanks for your sample! It illustrates your solution very well!

For some reason it didn’t work for me though. If i add a simple window to my project and call it from my main window, it works using your solution. My dialog needs to load some data though before it is shown which seems to negate the effect of the Timer.CallLater workaround. Plus my window is stored in a local property so i don’t have to load the data each time it is shown, which also seems to interfere with the workaround.

My workaround: Replace all lables which can be klicked on by bevel buttons since these react to their events in any situation and the caption can be left aligned if needed. Just need to apply the system background color. To get rid of the frame around the bevel button, i placed in inside a container control and moved it 4 pixels left and up (left = -4, top = -4, width = width + 8, height = height + 8).

So far, this does the job for me, since the problem only ever pops up with labels in my project.