Edit TreeGadget items?
Posted: Tue Sep 04, 2018 8:05 pm
Hi,
I'm trying to set it up so users can edit TreeGadget items, but it's safe to say I have absolutely no idea what I'm doing. I can't get it to start the editing. I'd like to be able to validate what they enter. Does anyone have any tips?
I started with this code by Shardik.
I'm trying to set it up so users can edit TreeGadget items, but it's safe to say I have absolutely no idea what I'm doing. I can't get it to start the editing. I'd like to be able to validate what they enter. Does anyone have any tips?
I started with this code by Shardik.
Code: Select all
EnableExplicit
Define AppDelegate.I = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Define DelegateClass.I = CocoaMessage(0, AppDelegate, "class")
Define Selector.I = sel_registerName_("tableView:viewForTableColumn:row:")
ProcedureC GetViewForCellCallback(Object.I, Selector.I, TableView.I, ColumnObject.I, Row.I)
Protected CellContent.S
Protected Column.I
Protected ColumnID.S = PeekS(CocoaMessage(0, CocoaMessage(0, ColumnObject, "identifier"), "UTF8String"), -1, #PB_UTF8)
Protected View.I
View = CocoaMessage(0, CocoaMessage(0, 0, "NSTextField new"), "setEditable:", #YES)
ProcedureReturn View
EndProcedure
OpenWindow(0, 200, 100, 430, 126, "")
TreeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20)
AddGadgetItem(0, -1, "Harry Rannit")
AddGadgetItem(0, -1, "Ginger Brokeit")
AddGadgetItem(0, -1, "Didi Foundit")
class_addMethod_(DelegateClass, Selector, @GetViewForCellCallback(), "v@:@@@")
CocoaMessage(0, GadgetID(0), "setDelegate:", AppDelegate)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow