Unable to enable all Childs of a Menu

At drop time, I add dynamically the name of the dropped files in a Menu (Recents *)

To achive that, I added a Class that I called RecentsMI, with MenuItem as Super.
I add the Action Event and put the code below:

[code]// Get the dropped file name
muName = RecentFI.DisplayName

// Set the Name and Text properties of the MenuItem
RecentMU.Name = muName
RecentMU.Text = muName

// Store the FolderItem Reference into the MenuItem Tag
RecentMU.Tag = RecentFI

// Append the MenuItem for the dropped file
RecentsMenu.Append RecentMU

// And enable the newly added MenuItem
RecentMU.Enabled = True[/code]

I tried to enable the MenuItems here or there, but to no available…

BTW: I dropped two items into the window and the code really adds two Menuitem entries into my Recents Menu.

I also make a search (on my Hard Disks) for Recent (returns also Recents), but nothing was found. (Finder Search does not search inside Xojo files [projects])

MenuItem entry in the docs was of no help (or I do not know where to search.

The OpenRecentMenu was created at the time of Mathusalem’s father (or Line Renaud first phonograph cylinder record). So, no help from there.
I am once again walking beside my shoes…

At this point, I am asking you for help.

  • Yes, I choosed to use a Menu and not a sub-menu in the File Menu.

I don’t know how your Class works, how do you save the recent list?

here an example of my version.

I changed it to use it as Menuitem ( not Submenu of File)

Hi Axel,
Thank you for the example.

I used a local variable to add the MenuItems instead of the reference of the Menu in the MenuBar.
It tooks me hours to achive the simple addition.

I specialized the whole code to get images drop, put the name (MenuItem) / references (Tag) in the Recent(s ?) Menu and display the image when a MenuItem is fired.

And I stopped yesterday on a failure to implement that in another project (where I want to really use it). It was good to build a proof of concept because I notices something I did not think at previously: what about dropping two or more times the same element ? They will appears… twice, thrice, etc. I failed there: at the point where I checked if there is an element with that name.

I falled onto other traps earlier today and will resume working on it this afternoon.

Hi Axel, all,

here is my version of the Recent Menu application.

Per se, this example is a bit stupid: I’d better display directly the image in the window backdrop ;-:slight_smile:

BUT: since I started this conversation and Axel example, I created my version of the project to share it here.

I also take the opportunity to create an application icon (App.icns) and set a Post-build script to apply it into the Application’s Resource folder.

How to use this example ?
Run it in the IDE,
Drop one or more images in the front window,
Fire one or many MenuItems corresponding to the dropped images.

Or: Build the example, see the application’s icon and… run it, drop image(s) and fire some menu item(s)…

Note that the main window will be resized to fit the dropped image: avoid to drop a very large image, larger than your monitor.

What can I say more ?

Yes, I know: in wMain.DropObject, some code is useless for Indows (and Linux, certainly). It is the code that check if the dropped item is a directory and the second if block that check if the dropped object type exists in the FT_Imgs.All string.

At last, I do not set any error code

How to improve this project ?
Add some more image file types (and pdf) ?

No, seriousy: use it at will, but I do not think about a use for it.

Oh, yes, I know: add code to avoid add duplicated MenuItems…
Add a Clear Menu ? Check how Axel do in its example.

“Table of Contents”
a. Allow drop of image files ()
b. For OS X, exclude Folder and non defined images files drops
c. Populate a Recent Menu
d. Allow one or many drops
e. Copy the App.icns Icon into the built application
f. All of this: free of charge.



one problem
If the file extension is hidden (OSX), the line remains empty


// Get the dropped file name muName = RecentFI.DisplayName


// Get the dropped file name muName = RecentFI.Name

Thanks. Usually, here, file extension are visible (on OS X, Invisibles on Windows 8.1).

But, it could be that some (of my) files does not shows their extensions.

New version available here.

Then, you can get a pdf (where and how to below) and drop it into the window, then choose its entry


In the web page, left part, click in the text (watch below) to get today newspaper’s front page:
Télécharger gratuitement la Une en PDF

DNA: Dernières Nouvelles d’Alsace (last news from Alsace, more or less).