[Gambas-user] Disable right click popup menu of textbox

T Lee Davidson t.lee.davidson at gmail.com
Wed Sep 30 19:29:19 CEST 2020

On 9/30/20 7:28 AM, Angel wrote:
> Hi.
> Your example does work for me, the one that doesn't work for me is my example, if I ting the popup menu with
> $hText.PopupMenu ? "mnuTextbox"
> event CajaTexto_MouseDown().
> The first object that launches the menu receives all events, even if you are on another object.
> If I ting the popup menu with a variable of type Menu,
> If it works but once my popup menu is closed, the textbox menu is launched, the two menus come out.
> I don't know if I've explained myself well, my English is very bad.

With the project you attached, I get only one popup menu; and it is your custom menu.

However, you are correct that the first TextBox created receives all the events. That is because each one is given the same 
event name (with: As "CajaTexto"), and each popup menu is also given the same event name (with: As "mnuTextbox") making all the 
textboxes use the first textbox's event handler and menu. The first one defined obviously takes precedence.

I have attached a modified project in which:
1) The popup menu definition has been moved to the _new subroutine since it does not need to be defined per each event.
2) Each TextBox gets its event name from its name, ie. As Me.Name.
3) Each popup menu gets its event name from its TextBox name, ie. As "mnu" & Me.Name.

As long as the popup menu property of the TextBox is properly set, the MouseDown event is not needed.

And by the way, changing the value of iBackground appears to have no effect.


More information about the User mailing list