Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Tue Nov 16, 2010 8:52 pm
...but does not clear the UI where the sort arrow remains...
http://www.purebasic.com
https://www.purebasic.fr/english/
No, you're right.linkerstorm wrote:...but does not clear the UI where the sort arrow remains...
No.Fangbeast wrote:Gnozal, is it possible to sort on more than one column at a time?
I.e: I have a time and date field and I want the date field to be sorted first and then the time field for each date?
Code: Select all
;
; PureLVSORT listicon editing example
;
Procedure.l MyEditCallback(Event.l, ListIconNumber.l, Column.l, Row.l, text.s)
Debug "*** EDITING CALLBACK"
Select Event
Case #PureLVSORT_EditStart
Debug "ListIcon = " + Str(ListIconNumber)
Debug "Column = " + Str(Column)
Debug "Row = " + Str(Row)
Debug "-> Editing started"
;ADDED
Debug ListIconNumber
;
; Return : - 0 to enable stringgadget
; - *string to enable spingadget [the string holds the choice items]
;
ProcedureReturn @"700|800|900|1000"
Case #PureLVSORT_EditText
Debug "ListIcon = " + Str(ListIconNumber)
Debug "Column = " + Str(Column)
Debug "Row = " + Str(Row)
Debug "-> Text = " + text
;ADDED
Debug ListIconNumber
;
; Return : - 0 to keep the text
; - *string to change the text [the string holds the changed text]
;
If text = "Change this text"
ProcedureReturn @"to another text"
EndIf
Case #PureLVSORT_EditEnd
Debug "Editing ended"
;ADDED
Debug ListIconNumber
Case #PureLVSORT_EditEscape
Debug "Editing cancelled"
;ADDED
Debug ListIconNumber
EndSelect
Debug "******************"
EndProcedure
;
#Window_0 = 0
#ListIcon_0 = 100
Procedure Open_Window_0()
If OpenWindow(#Window_0, 0, 0, 602, 302, "PureLVSORT Make Editable Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
ListIconGadget(#ListIcon_0, 5, 5, 590, 255, "String", 100)
AddGadgetColumn(#ListIcon_0, 1, "Numeric", 110)
AddGadgetColumn(#ListIcon_0, 2, "Float", 110)
AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120)
AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120)
AddGadgetColumn(#ListIcon_0, 5, "DateMMDDYYYY", 120)
AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "1000" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004" + Chr(10) + "12/31/2004")
AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "700" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004" + Chr(10)+ "12/11/2004")
AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "800" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10)+ "12/11/2004")
For n=1 To 25
AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "extra entry "+Str(n) + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10)+ "12/11/2004")
Next
EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnFlag(#ListIcon_0, 0, #PureLVSORT_Column_Hidden) ; Hide column 0
PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String)
PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_Numeric)
PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_Float)
PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY)
PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY)
PureLVSORT_SetLastColumnAutoResize(#ListIcon_0, #True)
PureLVSORT_MakeColumnEditable(#ListIcon_0, 2, #True) ; Column 2 is editable
PureLVSORT_SetEditingColors(#Red, #White)
PureLVSORT_SetEditingCallback(@MyEditCallback()) ; Set editing callback
EndIf
;
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EndSelect
Until Event = #PB_Event_CloseWindow
End
Yes, it its.QuimV wrote:In the events #PureLVSORT_EditEnd and #PureLVSORT_EditEscape, ListIconNumber is equal to -1.
Is that correct?
Code: Select all
;
; PureLVSORT listicon editing example
;
Procedure.l MyEditCallback(Event.l, ListIconNumber.l, Column.l, Row.l, text.s)
Debug "*** EDITING CALLBACK"
Select Event
Case #PureLVSORT_EditStart
Debug "ListIcon = " + Str(ListIconNumber)
Debug "Column = " + Str(Column)
Debug "Row = " + Str(Row)
Debug "-> Editing started"
;
; Return : - 0 to enable stringgadget
; - *string to enable spingadget [the string holds the choice items]
;
ProcedureReturn @"700|800|900|1000"
Case #PureLVSORT_EditText
Debug "ListIcon = " + Str(ListIconNumber)
Debug "Column = " + Str(Column)
Debug "Row = " + Str(Row)
Debug "-> Text = " + text
;
; Return : - 0 to keep the text
; - *string to change the text [the string holds the changed text]
;
If text = "Change this text"
ProcedureReturn @"to another text"
EndIf
Case #PureLVSORT_EditEnd
Debug "Editing ended"
Case #PureLVSORT_EditEscape
Debug "Editing cancelled"
EndSelect
Debug "******************"
EndProcedure
;
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
If OpenWindow(#Window_0, 0, 0, 602, 320, "PureLVSORT Make Editable Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
ListIconGadget(#ListIcon_0, 5, 5, 590, 255, "String", 100)
AddGadgetColumn(#ListIcon_0, 1, "Numeric", 110)
AddGadgetColumn(#ListIcon_0, 2, "Float", 110)
AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120)
AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120)
AddGadgetColumn(#ListIcon_0, 5, "DateMMDDYYYY", 120)
AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "1000" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004" + Chr(10) + "12/31/2004")
AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "700" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004" + Chr(10)+ "12/11/2004")
AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "800" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10)+ "12/11/2004")
For n=1 To 25
AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "extra entry "+Str(n) + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10)+ "12/11/2004")
Next
;ADDED
ButtonGadget(1000,5,260,590,60,"Click here and ListIcon lose focus, but not abandon the edit state. PureLVSORT_EditEnd is sent if the Listicongadget loses focus?", #PB_Button_MultiLine)
EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnFlag(#ListIcon_0, 0, #PureLVSORT_Column_Hidden) ; Hide column 0
PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String)
PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_Numeric)
PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_Float)
PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY)
PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY)
PureLVSORT_SetLastColumnAutoResize(#ListIcon_0, #True)
PureLVSORT_MakeColumnEditable(#ListIcon_0, 2, #True) ; Column 2 is editable
PureLVSORT_SetEditingColors(#Red, #White)
PureLVSORT_SetEditingCallback(@MyEditCallback()) ; Set editing callback
EndIf
;
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EndSelect
Until Event = #PB_Event_CloseWindow
End
Sorry, my statement was incorrect.QuimV wrote:I tried this piece of code and it seems that the #PureLVSORT_EditEnd event is not fired when the ListIcon loses the focus. Is a correct behavior?
Did you try PureLVSORT_CancelCellEditing() ?QuimV wrote:When the user click another gadget and the ListIcon lose the focus, How could I end or cancel the current edition programatically?
Is it possible?