Two ContextualMenus for a ListBox

I made a simple ListBox for which a ContextualMenu is programmed. This works fine as long no cell is edited, however, when a cell is edited and a contextualClick is done in this cell, another (default) ContextualMenu appears (Cut, Copy, Paste, …). How can I prevent the appearance of the default ContextualMenu and show the ContextualMenu I programmed?
I use Xojo Release 1.1 with MaxOS High Sierra.

Marc

Marc,

in this kind of question I will suggest to make a simple test project to demonstrate the trouble (screen shot is not enough), so if someone want to verify (or more: propose a solution, point where an error is, if any), a simple click to download the sample project and here (s)he is…

Did you try with different Xojo and OS versions ?

The other ContextualMenu may be attached to the TextEdit (TextField or TextArea) actually in Edit mode ?
Do you think you do that ?

Probably, it is a ‘bug?’ present in the ListBox. When you check the example projects as delivered with the Xojo application (Example Projects -> Desktop -> Controls -> ListBox -> ListBoxExample) the same problem with the ContextualMenu occurs.
Right clicking in a cell that is not edited gives the ContextualMenu as programmed for the ListBox. When a cell is edited another default ContextualMenu appears. This is very annoying but I am afraid it will be difficult to solve by a user of Xojo.

Even while i am not sure if this is a Bug, i’d recommend to make a Feedback Report because this should be changed/fixed.

[quote=394933:@Marc De Block]Probably, it is a ‘bug?’ present in the ListBox. When you check the example projects as delivered with the Xojo application (Example Projects → Desktop → Controls → ListBox → ListBoxExample) the same problem with the ContextualMenu occurs.
Right clicking in a cell that is not edited gives the ContextualMenu as programmed for the ListBox. When a cell is edited another default ContextualMenu appears. This is very annoying but I am afraid it will be difficult to solve by a user of Xojo.[/quote]

Dave gave you the explanation, but it may have been a tad cryptic.

The listbox has it’s contextual menu alright, which displays as expected, until you edit a cell. Why is that ? Because as soon as you edit a cell, you are using a TextEdit, which is ListBox.ActiveCell. http://documentation.xojo.com/index.php/ListBox.ActiveCell

Unfortunately, it does not seem possible to modify it’s edit menu, which is not the regular edit menu. I tried to addhandler the constructContextualMenu to no avail.

It is not a bug per se, but you may want to file a feature request in Feedback to have access to listbox.ActiveCell contextual menu.

I will make a Feedback Report. Thank you for the suggestion.

What a strange idea !

Did you try to avoid that using the TextEdit (TextField or TextArea) reference ?

Edit: I just checked with a 20A5r1 built application: this was already like that.

As long the cell is not edited: a right-click can edit the cell (this can be programmed in the ContextualMenuAction) and in this case the ‘wanted’ programmed ContextualMenu is edited.
The ‘wrong’ ContextualMenu is displayed when the right-click is done in an already edited cell.

That is what I wrote earlier and yes, this was already the case with Xojo 2015r1 (standalone application).

One work around (one that I use in programs like Tadpole)… is to NOT use the built-in “active cell”, but to create a subclass custom control that is a listbox and textfield, and move the textfield over the listbox to simulate cell edit (which is most likely what the native box does, just not as well). This way you have access to all the bits, and can control them as you please. It also gives the ability to have cell based drop menus, and other fancy stuff.

I noticed that some things are possible to be done with the built-in TextField or TextArea (depending on what the developer choose as the ActiveCell TextEdit), but some were not working.

Good catch Dave. That is an idea that I never had.

I implemented Dave’s idea and indeed it works.
I learned a lot about the possibilities of ‘TextEdit’, … and a rather straightforward solved the problem.

Many thanks to all of you!!!

Marc