Listbox content change handler

Hello there

I’m new in Xojo Desktop App (for macOS). I make some tests and I don’t found in the documentation an event handler for ListBox content change. Is there an Event Handler for that ? Unfortunately it’s not Change event handler.

I need to change my UI whether Listbox is Empty or not. From previous languages I came from it’s a kind of observer. Maybe, the only solution is to create my own observer methods. I think I already view a YouTube video tutorial about observer pattern in Xojo

Regards

http://documentation.xojo.com/api/deprecated/listbox.html#listbox-change

@Emile Schwarz thank for your reply but according to the documentation, the change event handler is called in response to the following user actions:

  • When the Listbox is clicked to giv[s]e it the focus
  • When an empty row in the ListBox is clicked
  • When a cell is clicked even if it already is selected and the column is not editable
  • When a row is clicked to change the selection[/s]

It’s not called when the content change by code (when adding / removing row, cell, etc.

What do you want to do with the content changed event? As you already are in code you can do a subclass of the listbox. There you do an event definition “ContentChanged”. You do a

raiseevent contentchanged

whenever your code does a change.

@Beatrix Willius, thanks for you reply

I want to update my user interface when my ListBox content change for example : Set visible = false for a Delete PushButton when the Listbox is empty also Set a label text to “Create your first item”, etc…

make an empty desktop project
drag a listbox in the window1
add en event to the listbox, choose 'change"
you see beside it an explaination of what this event does :

just tested it, the change event is called when you change the listbox.listindex property.
it is not called if you use listbox.addrow method

It is also fired when the user click outside of the populated rows: if your ListBox have 5 Rows and can display 10 Rows, a click in Row 10 (for example) fire the Change event.

Thanks everybody but Change Event is not the solution cause it need user interaction like select row, select cell, etc…, real interaction or simulate by code. This is definitively not what I’m looking for.

It really is dependant on what you want to do. Please describe in more detail.

Here is a very simple database listbox:

You can always add a new mailbox. The button to delete a database is not always enabled. There is only one method to load data. Therefore, at the end of the data loading I have a method to enable and disable the buttons. The same method is done when the selection is changed.

If your interface is going to be more complex then the observer pattern might be a good idea. In other situations I have used the events I proposed earlier. Or I the parent object gets the number of selected items.

[quote=484146:@Sebastien REMY]Hello there

I’m new in Xojo Desktop App (for macOS). I make some tests and I don’t found in the documentation an event handler for ListBox content change. Is there an Event Handler for that ? Unfortunately it’s not Change event handler.

I need to change my UI whether Listbox is Empty or not. From previous languages I came from it’s a kind of observer. Maybe, the only solution is to create my own observer methods. I think I already view a YouTube video tutorial about observer pattern in Xojo

Regards[/quote]

you’re looking for some event that is triggered when CONTENT is added & removed ?
not when a user or code makes a selection (which is what change does)