PopupMenu - serious bug

I need the MouseUp event of a PopupMenu.
To fire this event, you need to Return True in the MouseDown event.
But when you Return True in the MouseDown event, the menu cannot be shown !! Rendering the PopupMenu useless when you need the MouseUp event.

For me a serious issue !!

<https://xojo.com/issue/33662>

Maybe we can approach this from a different direction. Why do you need to do this? What do you plan to do in MouseUp?

I don’t consider this a bug at all. Return True means that you have handled the event yourself. So if you Return True, then it’s up to you to display the popupMenu menu. What would you have Xojo do? If they changed the behavior of Return True, then that wo uldmake the language very inconsistent. As Kem suggested, what are you trying to get at?

The problem is, even if you want to handle it yourself, I don’t see a way to force it to pop up manually.

Here is how to have your cake and eat it too. See :

  • Add to your page :

popupmousedown As boolean

  • Add to your popmenu :

Function MouseDown(X As Integer, Y As Integer) As Boolean popupmousedown = true End Function

  • Add a timer to your page with a period or 100 or less, and add to it :

[code]Sub Action()
if system.MouseDown = false and popupmousedown = true then
popupmousedown = false
//do whatever you need to do in mouseup

end if
End Sub
[/code]

You got the same event as mouseup. If you need X and Y copy them to windows properties in PopMenu.MouseMove.

… Now that you have a mouseup for your PopupMenu, may I ask what it is you have to do there that could not be done in MouseDown ?

Michel’s solution is very nice. You can also turn that into a subclass with an internal Timer so it raises some Event for you.

Yes indeed, the technique can be made into a class around the popupmenu and a method will nicely add an event. Good point.

For cocoa, you can call preformClick and return true… then you still get the changed and mouseUp events :slight_smile:

me.NSPopUpButtonMBS.performClick Return true
or

[code] declare sub performClick lib “Cocoa” selector “performClick:” (obj as ptr)

performClick(ptr(me.handle))

[/code]

Is it a context popup menu? If so:

If IsContectualClick Return True End if

As always Jim, you are awesome.

I am going to call you Jim-The Declareman-McKay :slight_smile:

Seriously, you are the first giving so much useful declare stuff for us OSX devs ! Thank you for this, really appreciated.

[quote=90958:@Christoph De Vocht]As always Jim, you are awesome.

I am going to call you Jim-The Declareman-McKay :slight_smile:

Seriously, you are the first giving so much useful declare stuff for us OSX devs ! Thank you for this, really appreciated.[/quote]

Jim is indeed extremely brilliant using an MBS plugin or a declare. Nevertheless Christoph, even if my pure Xojo solution does not have the same glitz, I was the first to post a working solution built and tested for you. It feels terrible to be ignored entirely. Ouch !

Hmm, thats something I expect my little daughter of 6 year would say.

Anyhow, in this case Jims way is much easier, not? But hey, I do appreciated every input. :slight_smile: No hard feelings.

I expect you’ll get more people willing to help in the future if you acknowledge those who tried to help you in the present. Nobody is obligated here, and a “thank you” goes a long way.

True, thats why I also Liked Michel solution. But he probably didn’t noticed that.

OT: There is always a good reason for what we are doing. For instance the good reason for posting answers into this forum may be that we simply like it when we see that we can help and support others. And then of course everybody likes it as well to see that ones efforts are appreciated.

Now one can say that life is teaching us to better not to have expectations for a return of investment… well, still it is true that we enjoy it, when we get what we like to see in our life. Like appreciation.

So I hope that on the next occasion I will remember my own words and express my appreciation for all of you, who make this platform so valuable. Through your work I am learning every day - and this is one of the things I really like.

I do like to help, but I am really driven by “Hmm… interesting question. I wonder if this would work…”

On that note…
If anyone needs a win32 solution, placed in the mouseUp event, this works and you still get the “Change” event :wink:

[code] #if TargetWin32 then

const CB_SHOWDROPDOWN = &H14F
Soft Declare Function SendMessageW Lib "user32" Alias "SendMessageW" ( hwnd As int32,  wMsg As int32, ByVal wParam As uint32, lParam As uint32) As int32
dim ok as integer=sendmessageW(me.Handle,CB_SHOWDROPDOWN,1,0)

#endif
[/code]

Also, I did like Michel Bujardet’s answer, but I always like to see if the OS can do the work for me.

Always good to see nice and grateful people around :confused: No good deed goes unpunished…

Again, I am grateful with your solution (Liked it too btw). But still not sure why you were moaning because I thanked Jim for his (better) solution.
So if you still not get it: THANK YOU FOR YOUR INPUT AND SOLUTION. Ohboy …

Lets move on…

[quote=91064:@Christoph De Vocht]Again, I am grateful with your solution (Liked it too btw). But still not sure why you were moaning because I thanked Jim for his (better) solution.
So if you still not get it: THANK YOU FOR YOUR INPUT AND SOLUTION. Ohboy …

Lets move on…[/quote]

You are welcome. Still, why do you insist on making me feel like I insulted you ?

Sorry for trying to help (oh boy).

Really?

You were clearly pointing at me saying I ignored you, which I didn’t.

Anyhow, I marked your answer as the correct one. Just let it go now…