Editable Cell and ContextualMenu ?

In a Listbox, I set (some) Cells as Editable. Good, nice !

I also added a Contextual Menu to be able to put directly from a predefined list some text in the Clicked Cell.

But when I right-Click (or Ctrl+Click) in a Cell ( selected or non selected Cell), I do not get the ContextualMenu.

Nota: on macOS, I can get the ContextualMenu (not always I think, but often).

Is it possible to do something and if so, any clue ?

Seems not to be possible: listbox.activecell contextual menu ?.

Thank you Eli.

There is a big problem here: either my brain start to be is some disorder or I found more Xojo impossible features than I ever found in the past years…

Doh ! I found something better on WIndows 10 1709 than in macOS. When one press Return (or Enter) while in Listbox Cell edit mode, the focus stays in that Row (WIndows) while it “goes away” from the Listbox in macOS (El Capitan)…

I found a workaround for half of the problem :frowning:

I put the code below in the ContextualMenuAction Event, before I execute the actual code (on top of all code).

If Keyboard.ControlKey Then // Si la Cell est ditable Me.CellType(gClickRow,gClickColumn) = ListBox.TypeDefault End If

So, when I ctrl-click, I can see (and I have) the Contextual Menu, and I can use it (it paste some predefined text).

Now, my question is how to trap a right-click ? The quest continue

PS: too late for me now, but I am wondering if it would have been a better idea to be an archaeologist instead of working in the Computer business
(an archaeologist is a researcher who sometimes found / sometimes search for years until something happens)

Out of interest, what is the requirement for CTRL+Click to emulate a right click, it doesnt seem like a windows standard which is why I ask? If you want this, it can be done quite easily with declares. Let me know and I’ll throw some code your way.

Is this what you want for the rest of the menu system?

https://www.dropbox.com/s/u36ns92mfo69va1/TestRightClickListbox.xojo_binary_project?dl=1

I’m not really sure where you are having problems as I haven’t seem to come up against any problems making this example, perhaps I’m missing something that you need in there?

Hi Julian,

I go back home right now and get an eye on your example from there.

Thank you.

Ctrl-Click on a Mac is the same as a Right-Click with the mouse.

The problem here is to build a contextual menu for a cell being edited, not for the listbox itself. It is not possible, because AddHandler does not work as expected for the ActiveCell of a listbox:

AddHandler lbx.ActiveCell.ConstructContextualMenu, AddressOf EditCellConstructContextualMenu AddHandler lbx.ActiveCell.ContextualMenuAction, AddressOf EditCellContextualMenuAction

If ctrl-click on a mac is the same as right click then my example should work there too (no tested, let me get my laptop out).

Whats the difference between using the context menu through the listbox vs creating your own menu in the edited cell?

You can still generate the menu to your exact requirements in code when brought up in the cell.

I’m not understanding the problem, sorry.

I think the problem is that the code works on Windows and not on Mac.

Oh, Targets>Windows threw me. Yeah, just tested it on mac and the standard context menu appears when the cell is being edited, thats a shame.

You might want to throw this into Targets>macOS to get more eyes on it?

I re-read the thread, my English is not that great, I don’t know if Emile target is Windows or Mac, or there is a need to work in both.

Hi all,

I build the project on Mac and it is meant to be running on Windows. Very simple !

I tested my project yesterday afternoon on Windows 10 1709.

Feedback:
a. If the ActiveCell text is selected, the built ContextualMenu shows a list of entries created by the OS (Mac).
b. If a Cell is in Edit Mode, I can both ctrl-Left-Click and Right-Click on a different Cell to get the ContextualMenu.
c. Now, I cannot anymore type somthing in the ActiveCell while it is possible to do so with Julian example project.
d. I do not know what to say about the troubles I have with Xojo (of course I know, but my mother was against this kind of sentencces).

I use REALbasic, Real Studio, Xojo since… 20 years (nearly); a lot of experience… to be stopped here.
In september / october, I had to change my mind (design) many times because of Xojo limitations (where I am able to have creative thinking…)
A real shame.

OK, I know. That project was created on September 11, 2017 @ 15:00 (France time). No, this is not funny.
Since then, when somethingis not working, I stop that and start a new feature. Then, sometimes I discover some strange things like… a newly added window does not have a MenuBar (not even the default one). I had to add the default MenuBar yesterday on around 10 windows, to be able to navigate (display) these windows on Windows 10.
I do not falled onto that trap because I tested each individual window (and to do that, I set the testing window as the default window).

The problem is not a lack of time (to deliver the product), but I’m getting tired of this project (Xojo).

I think you might have found a bug here, in Windows you get the following order on the events:

CellClick
ConstructContextualMenu

but on macOS they are reversed:

ConstructContactualMenu
CellClick

This only happens when using ctrl+click on macOS.

When you use right mouse on macOS its different again:

CellClick

No other events are raised, so you’ll never get a chance to create your own menu.

Xojo (Norman?) gets around this in the Xojo IDE in the Xojo Prefererences > General > Edit (Menu short cuts) by only allowing the right click only when the entry is not in edit mode.

Not only are the events firing in different order which makes crossplatform behaviour a nightmare but as you can override the context menu on a textbox you should be able to override it in the listbox in edit mode in a similar fashion, hence why I think this is a bug.

I cant find anything about it in feedback either.

From a UI experience perspective, having a context menu on a listbox is pretty hideous. I didnt actually realise that you could do that in Xojo on the menu short cuts editor until I was trying to break the thing during testing as there was no indicator to show that it could be done.

Personally, unless you are cloning excel, I’d either go with an editable combo box with a drop down list of your options or another column with a \/ (or menu icon) showing the user there can click there to open a popup menu. Hidden context menus are a bit 90’s, just imho :wink:

You could always used an external textfield or text area that you move over a cell to edit… that is what I do with my Mergeable Cell Listbox subclass

  • karen

Seems like a decent feature request to have an event “GetActiveCell” or something that returns a TextField or TextArea
This would let you control what subclass got returned so you could have more control over things like contextual menus etc

Hi Julian,

That is probably why I wanted to use an AutoComplete feature.

Not only that, but (as you probably wrote), the users - unless I told them - will never know nor discover that feature :frowning:

Thanks for testings/ answering all.

BTW: I just recall what I tried yesterday (before I cannot edit the Cell anymore ?): I tried to add a Mask (a test for another part of the project: can I add a Mask in a Listbox while running; pretty stupid: I do not tried what I wanted to do :frowning: ).

BTW: I use in another project a ContextualMenu to make Column operations (Copy, Cut, Paste, Clear on the whole clicked column) and this does not annoy me (as a user) to do that. “Worst”: I really like that feature !

I was foolhardy earlier today and tried to understand why I cannot type text anymore in my Cell.

First of all, I deleted the TextField SubClass,
Cleared the associated code (code I added yesterday to deal with the SubClass),
Save the project,
Run: still no more able to edit the clicked Cell.

I cleared the Xojo cache folder,
Power Off,
Run a different user (same result: sameXojo application),
Put the used Xojo into the trash
and copy a brand new one from the original DMG,

same behavior.

I tried a project from earlier yesterday (before I tried to use the TextField SubClass: still bad.

I exported the “offending” window, create a brand new project,
Imported the “offending” window,
Set that window as the default one,
Cleared Window1,

Run: Still no more able to type something in the ActiveCell.

Edit: I nearly forgot. I boot on the Recover partition and checked the boot (internal) SSD. All is clear.

I may try to build for Windows and test on VirtualBox’ WIndows XP (I do not have my Windows 10 laptop with me to make the test).

On Windows XP (running 2015r1), a right-click select the cicked Cell, but displays the ContextualMenu AND put the selected entry (the text of the selected entry) into the Cell.

This can be seen once another Cell is selected…

On the other hand, I am still no more able to edit a Cell contents (a selected Cell: the ActiveCell !)

I will add a new Listbox in that project window, Copy / Paste code from the actual LB into the new one, clear the old one and watch what happens.

(I already do that when I cahnged my mind from using or not a Hierarchical Listbox).

Norman, all,

One more thank for your help.

At last, when I get back home for lunch, after some hours, I found why I cannot type text in the ActiveCell.

Before I get sick (when I woke-up from my afternoon nap), I decided to create a brand new window (the one that have the problem: in a different window, the simple two lines to set a Cell as Editable worked fine. That behavior was in that window) with the same contents (but I added new Controls.

After a while, I was adding the LostFocus Event (in the Listbox) and put this line of code: Me.SetFocus.

Then I ran the project (for the xxxth times, each time after I add something to the window) and that was it: the Cell was no more editable.

So, I checked in another project where I do the same and noticed that I used the wrong Event. The correct one (to keep the focus on the Edited Cell’s Row: needed on macOS, not on Windows).

So, I deleted LostFocus and add CellLostFocus, paste the code there and I am now be able to type text in the ActiveCell.

Since the Listbox lost the focus at the end of the typing process, this was (my) obvious choice; a bad choice.

Now, back to bed and wait 'till (if) I get back well and I will have to decide if I will continue or stop….