Create new object

Just trying to gasp the basics of working with objects…

I have created an new class (mPopMenu) which is a subclass of DesktopPopupMenu
In it I have written some code on the opening event:

me.AddRow("Janvier")
me.AddRow("Février")
me.AddRow("Mars")
me.AddRow("Avril")

When I drag and drop such an object in my app window in the IDE it works fine
Now, I’d like to create such object “on the go”. When my user presses a button for instance. Therefor in a button press event I wrote this code:

var pop As mPopupMenu
pop = new mPopupMenu

pop.Name = "Yes"
pop.Left =314
pop.top = 200
pop.Width = 50
pop.Height = 20
pop.Visible = True
Window1.Refresh

But nothing happens in my window…

You need to use DesktopWindow.AddControl (DesktopWindow — Xojo documentation).

Probably it’ll good for you to study the docs, which helps a lot with such kind of questions.

var pop As mPopupMenu
pop = new mPopupMenu

pop.Name = "Yes"
pop.Left =314
pop.top = 200
pop.Width = 50
pop.Height = 20
pop.Visible = True

Window1.AddControl(pop)
1 Like

Thank you!

Yes, but as a beginner I need the vocabulary to search into the documentation.

I looked a many different things like “New” which seemed to do the job… Anyway documentation is good but laks some feateures like the possibility to bookmark a page for instance.

Anyway thank you,

Download the pdf from there:

1 Like

Thank you Emile,