MouseUp event on Mac notebook not working(?)


I’m working with a MacBook Pro (Catalina) and the implemented trackpad.
I just wanted to define a MouseUp event on a textbox. In order to test it I put a MessageBox in it. The event does not fire (message not displayed).

Then I tried the MouseDown event the same way and it was working!

Anyone has an idea why the MouseUp is not working on the Apple notebooks?

Hi Farai, make sure you are returning True in MouseDown. MouseUp won’t fire unless you do so.

Aaaaah, got it, tnx!

First time I see one event is dependant on another event. Well, now the MouseUp is firing but the cursor will not be positioned where I clicked the mouse in the textarea.

Did you click inside text ?

@Emile Schwarz Of course. The cursor stays where it was before as nothing happened.

Code in MouseDown now:

Return True

Marking text with mouse is also no more possible as it wouldn’t react on my mouse anymore.

I could find a solution. I post it here for anyone else having the same issue:
Create a Timer f.e. with name MyTimer
RunMode: Off (this makes sure your Timer will not fire on starting the app)
Period: 100

In your MouseDown event put:


This will execute your timer (even previously put RunMode: off) and after 100ms the cursor in the textarea is positioned. So the MyTextarea.SelectionStart has a the correct value.

This is not a nice solution, rather a workaround. I have no idea why the mouse is blocked on a textarea with code “Return True” and I also don’t know why the MouseDown event must set to “Return True” in order to execute the MouseUp event. They both should act independent (imho).

Concerning my question @Gavin Smith has answered it.

When you return true in Mousedown, it snatches the even and does not let the control use it.

You got to ask yourself why you need MouseUp. And especially when.

Then return true only when you really need MouseUp.

@Michel Bujardet I’m calculating the current line and line position of the cursor for displaying purposes. This of course has effect on users mouseclick inside the textarea. The MouseDown event returns the existing (current) position in MyTextarea.SelectionStart but I need the new one. I then assumed that the MouseUp event would return the right position (set by mouse click). So this thread started…

I’ve made an error. I wanted to know if the MouseUp was done where you want the cursor be: in the middle of some text.

If you release the Mouse outside of the TextEdit, nothing will be done (from MouseUp)…

You have another way to get MouseUp without returning True in MouseDown.

Start a 15 Milliseconds multiple timer in MouseDown and not IsContextualClick with this kind of code in Action:

[code]If not System.MouseDown then
Sender.Mode = Timer.ModeOff
// Do MouseUp

End If

I don’t think you need to manage the cursor position if what you need is the selection, since you have SelStart and SelLength. But if you needed the cursor position anyway, you can obtain it with System.MouseX and System.MouseY, given that they are relative to the screen, and you would have to subtract the window position, and the position of the TextArea in the window.