Page 1 of 1
Cannot set Header text Of first column In listicongadget
Posted: Mon Jan 27, 2020 12:45 pm
by collectordave
When Checkboxes are used in the list icon the header text of column zero does not change but the header text of column 1 does. Seems there is a column -1! That does not change either.
Code: Select all
If OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(1, 10, 120, 330, 70, "Column 1", 100, #PB_ListIcon_CheckBoxes) ; ListIcon with checkbox
SetGadgetItemText(1, -1,"Item 1",0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Cannot set Header text Of first column In listicongadget
Posted: Mon Jan 27, 2020 3:07 pm
by mk-soft
In macOS the first column is that of the CheckBoxes, so the column '0' starts in the second column.
No Bug...
Re: Cannot set Header text Of first column In listicongadget
Posted: Mon Jan 27, 2020 3:21 pm
by collectordave
Thanks Saw that so how to set the header of the checkbox column?
The example works ok on windows.
While trying this cam across something else weird.
Code: Select all
OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(1, 10, 120, 330, 70, "Column 1", 100)
AddGadgetColumn(1, 1, "Address", 280)
ButtonGadget(2, 10, WindowHeight(0) - 30, 150, 25, "Set Header")
; SetGadgetItemText(1, -1,"Header 1",0) ; Sets Ok Here
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case 2
SetGadgetItemText(1, -1,"Header 1",0) ;But Not Here
EndSelect
EndSelect
ForEver
Similar thing no checkboxes.
Re: Cannot set Header text Of first column In listicongadget
Posted: Mon Jan 27, 2020 3:31 pm
by mk-soft
Link:
viewtopic.php?p=491692#p491692
Code: Select all
Procedure ListIconGadgetColumnTitle(gadget.i,index.i,title.s)
Protected column = CocoaMessage(0,CocoaMessage(0,GadgetID(gadget),"tableColumns"),"objectAtIndex:",index)
If column
CocoaMessage(0,column,"setTitle:$",@title)
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(1, 10, 120, 330, 70, "Column 1", 100, #PB_ListIcon_CheckBoxes) ; ListIcon with checkbox
SetGadgetItemText(1, -1,"Item 1",0)
ListIconGadgetColumnTitle(1, 0, "Ch")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Cannot set Header text Of first column In listicongadget
Posted: Mon Jan 27, 2020 3:38 pm
by mk-soft
Update Header over Button is a Bug
Is not redraw header
Edit
Bugfix for ListIconGadget
Code: Select all
CocoaMessage(0, GadgetID(1), "reloadData")
Code: Select all
OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(1, 10, 120, 330, 70, "Column 1", 100)
AddGadgetColumn(1, 1, "Address", 280)
ButtonGadget(2, 10, WindowHeight(0) - 30, 150, 25, "Set Header")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case 2
SetGadgetItemText(1, -1,"Header 1",0) ;But Not Here
CocoaMessage(0, GadgetID(1), "reloadData")
EndSelect
EndSelect
ForEver
Re: Cannot set Header text Of first column In listicongadget
Posted: Mon Jan 27, 2020 4:18 pm
by collectordave
Thanks mk-soft works well.
Still cannot set the header text on the checkbox column as per the help file though.
Regards
CD
Re: Cannot set Header text Of first column In listicongadget
Posted: Mon Jan 27, 2020 5:16 pm
by mk-soft
In macOS the CheckBox is a separate column and therefore Column 0 is the pure text column.
In Windows it is a single column and therefore column 0 is the check box and the text.
Re: Cannot set Header text Of first column In listicongadget
Posted: Tue Jan 28, 2020 4:21 am
by collectordave
So just an omission from the documentation then. Not the same on windows and mac.
Re: Cannot set Header text Of first column In listicongadget
Posted: Tue Jan 28, 2020 8:01 pm
by Shardik
collectordave wrote:Thanks Saw that so how to set the header of the checkbox column?
The following example demonstrates how to use Cocoa API methods to set the header text of a CheckBox column and increase the width of the column (tested successfully with PB 5.46 x64 in ASCII mode and with PB 5.71 x64):
Code: Select all
EnableExplicit
Procedure SetCheckBoxColumnHeaderText(ListIconID.I, Title.S,
ColumnWidth.CGFloat)
Protected *Column
*Column = CocoaMessage(0, CocoaMessage(0, GadgetID(ListIconID),
"tableColumns"), "objectAtIndex:", 0)
; ----- Check whether column 0 contains checkboxes
If PeekS(CocoaMessage(0, CocoaMessage(0, *Column, "identifier"),
"UTF8String"), -1, #PB_UTF8) = "CheckBox"
; ----- Increase width of column
CocoaMessage(0, *Column, "setWidth:@", @ColumnWidth)
; ----- Set header text of column 0
CocoaMessage(0, CocoaMessage(0, *Column, "headerCell"),
"setTitle:$", @Title)
EndIf
EndProcedure
OpenWindow(0, 200, 100, 490, 104, "ListIcon Example")
ListIconGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20,
"Name", 110, #PB_ListIcon_GridLines | #PB_ListIcon_CheckBoxes)
AddGadgetColumn(0, 1, "Address", GadgetWidth(0) - GetGadgetItemAttribute(0, 0,
#PB_ListIcon_ColumnWidth) - 51)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ +
"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ +
"130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Foundit" + #LF$ +
"321 Logo Drive, Mouse House, Downtown")
SetCheckBoxColumnHeaderText(0, "Select", 40)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Cannot set Header text Of first column In listicongadget
Posted: Tue Jan 28, 2020 9:56 pm
by mk-soft
Nice
I wanted to do the same, but didn't use CGFloat for setWith.
Re: Cannot set Header text Of first column In listicongadget
Posted: Fri Jan 31, 2020 11:39 am
by collectordave
Very nice,
Now my application looks almost the same in windows and MAC.
Should I ask for the documentation to be corrected?
Thankyou
CD