I have an app with a listbox that essentially contains a list of files. I currently have it coded so when you double-click the file in the listbox, you are brought into an edit mode. Now I want to add functionality… call it “format mode” for the same list of files. I’d like to be able to reuse the same listbox, but how can I tell my program when top go to edit mode vs. format mode? To open and load the listbox, I am using a simple button from the main window., so I think I somehow need to keep track of which button I pressed to get the window to load and then I can put some logic to say “If I originally pushed ‘edit’” go into edit mode, else if I pushed ‘format’ go to format mode"
Thoughts on the best way to handle this so I can reuse the same window & listbox when selecting for these two different functions?
Another elegant method could be the use of rowtags or celltags in your listbox. For instance mark an clicked/edited row with the rowtag “EDIT”. So you can keep track of them in your “format mode”. Add an icon to all marked rows, change colors or fonts e.g. and unmark your row with empty rowtag when your file/item/object is saved or edit mode cancelled.
I do this. I have a single-window program where the main listbox is used in all four stages of the process it manages. In each stage some or all of the previous rows are used (but displayed differently) and new rows may get added or removed as needed. I keep track of the window state (since the listbox is ruled by the stage of the process the window is in) and I keep all listbox data in an array. Events in the listbox flag and change the array which in turn is reflected in the listbox.
I’m currently trying to move this functionality to DTListbox with variable degrees of success, but will keep the listbox behaviour for non-mac platforms.