as I am coming from other GUI frameworks (like QT for Python) I am accustomed to create sometimes UI elementds also via code. I am wondering if this is possibile with Xojo too.
So I have started with some experimentation and added the following code to the
Pressed handler of a
var win as new DesktopWindow var btn as new DesktopButton btn.Caption = "push me" btn.Left = 50 btn.Top = 80 btn.Width = 150 win.Title = "Hello Window" win.Top = 100 win.Resizeable = true win.HasCloseButton = true win.HasFullScreenButton = true win.HasMinimizeButton = true win.Type = Types.Document win.Width = 600 win.Height = 400 win.AddControl(btn) win.Show
Once I run this, a new
DesktopWindow is created, but I don’t get the close, minimize, fullscreen buttons.
I am also wondering if there are other ways to pass properties to the
DesktopButton constructor, instead of manually setting every single property after instance creation.
Finally I was not able to add an event handler to the
DesktopButton. I have tried with the
AddHandler keyword, but I have got a syntax error message, using the following code:
Sub onClose(sender as DesktopButton) win.Close end Sub AddHandler btn.Pressed, AddressOf onClose
Thank you in advance