egrid-2 gadget - REMOVED (see version 3 - separate thread.)
Posted: Sun Apr 09, 2006 10:41 pm
REMOVED.
Prior to an all new version being released.
Prior to an all new version being released.
http://www.purebasic.com
https://www.purebasic.fr/english/
Thanks.mskuma wrote:Hi srod. This is excellent work, really useful. Thanks alot!
Consider yourself excused!I'm a newcomer to egrid (I see it's had some history) and to list gadgets in general, so please excuse my basic comments, questions & suggestions.
Uhm, I'll think about that one....but there seems to be no way to update a checkbox value via a keyboard? At least, space bar to toggle check on/off would be good.
This is the way I designed it I'm afraid and it suits me and my applications. I'm reluctant to alter this, although it would be a relatively simple adjustment to make. Tabbing (or pushing enter) between cells being edited keeps Egrid in 'edit' mode.Using the mouse to update values, I am not sure about the need to click once to select, then click again to edit, e.g. 2 clicks are required to change a checkbox value, whereas in the PB help example for listicon with checkbox, it is possible to click directly on a cell containing a checkbox to change its value (i.e. click once).
The answer is yes, using a 'CellCallBack' function.Same could be said for select/editing combo-box & text. Is it possible to make it so one click directly on the cell is enough to go into 'edit mode' (or see the combo-box options immediately)?
Whoops, that's a bug which is now fixed.I also wonder about double-clicking the 'between-part' of the column header (when the cursor changes to a column width resizer) i.e. whether this action should auto-expand the column width to match the text width in the same column, but I think the regular listicon doesn't do this either.
I've now found a quite major bug which I will endeavour to fix over the next couple of hours, so I will upload again when the fix is complete. Strange, this bug has been here since the beginning but has eluded me 'til now!Thanks again for making this great grid implementation available.
I could imagine that. It doesn't matter when you're mainly viewing the content, but if there were lots of edits, I think it would become quite tedious. I'd suggest a mode changing flag at the top of the program (the current mode, or 'single click' (to focus/enter-edit) mode. I wonder if the latter is the usual GUI/editing style for other windows apps (given the PB native operation, I assume it is the usual manner so in that case, this style is tending to work against what people might be used to. On the other hand, if it works for your current applications & users, I can't argue with either).srod wrote:This is the way I designed it I'm afraid and it suits me and my applications.
OK. If it's not tedious, maybe it's enough (instead of the flag idea above). I'll look into that.Same could be said for select/editing combo-box & text. Is it possible to make it so one click directly on the cell is enough to go into 'edit mode' (or see the combo-box options immediately)?srod wrote:The answer is yes, using a 'CellCallBack' function.
Was this fix included in the latest version? I'm wondering whether double-click expands to the width of the widest datavalue in the column, or to the width of the column (ala Excel)?srod wrote:Whoops, that's a bug which is now fixed.I also wonder about double-clicking the 'between-part' of the column header (when the cursor changes to a column width resizer) i.e. whether this action should auto-expand the column width to match the text width in the same column, but I think the regular listicon doesn't do this either.![]()
Sorry.. I'm not sure what was actually the problem - what was the issue? I can't immediately see any improvement (briefly looked at the 2nd demo, tabbing across columns).FIXED!!! (Swine tabstops! ) See above for details.
Yes it is included and columns resize to accomodate the widest value (this is simply the default for a ListIcon).Was this fix included in the latest version? I'm wondering whether double-click expands to the width of the widest datavalue in the column, or to the width of the column (ala Excel)?
I'm interested to have a look to your example, too.srod wrote:Have completed an example which shows how to enable one-click edit.
I will p.m. it to you.
Code: Select all
;******************************************************************************************
;'egrid' editable grid control. By Stephen Rodriguez.
;******************************************************************************************
;This example shows how to use a simple CellCallback function to enable one-click editing.
XIncludeFile "egrid.pb"
;The following simple CellCallback function allows us to enable one-click editing.
Procedure.l MyCellCallBack(egrid, uMsg, *cellinfo.egridCellInfo)
Protected result
Select uMsg
Case #egrid_SelectCell
;Check whether the cell was selected using the mouse.
If *cellinfo\param=#egrid_leftClick
egrid_HideEdit(egrid) ;Hides the selection border.
egrid_SelectCell(egrid, *cellinfo\row, *cellinfo\column, #True) ;Selects the cell.
;The '#True' value in the above line causes the selected cell to enter 'edit mode'.
result=#False ;No point getting the Egrid to select the cell as well.
Else
result=#True
EndIf
Default
result=#True
EndSelect
ProcedureReturn result
EndProcedure
;******************************************************************************************
;******************************************************************************************
;*************************************WINDOW + GADGET LIST*********************************
If OpenWindow(0,0,0,640,300,"One-click edit.",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize |#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
;******************************************************************************************
;********************************************EGRID*****************************************
;Create an egrid with resizable columns.
egrid_CreateGrid(1, WindowWidth(0)/4, WindowHeight(0)/8, WindowWidth(0)/2, WindowHeight(0)/2,21,#PB_ListIcon_GridLines, #egrid_ResizeColumnsTrue)
;******************************************************************************************
;**********************************SET CELLCALLBACK FUNCTION*******************************
;Set the callback early to avoid massive flickering when populating the egrid with initial data.
egrid_CreateCellCallback(1, @MyCellCallBack())
;******************************************************************************************
;***************************************ADD DATA TO EGRID**********************************
For b=1 To 50 ;50 columns. NOTE the column index begins at 1!
AddGadgetColumn(1,b,"Col " + Str(b),60)
Next
For b=0 To 9 ; Add 10 rows.
AddGadgetItem(1,-1,"") ;The "" is for the zero column which is always invisible in an egrid.
Next
For i = 0 To 9
For j = 1 To 50
SetGadgetItemText(1,i,"(" + Str(i) + ", "+Str(j) + ")",j)
Next j
Next i
;NOTE that the zero column of an egrid is blanked out, hence the "" in the above AddGadgetItem() command.
;******************************************************************************************
;*****************************************EVENT LOOP***************************************
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
EndIf
End
;******************************************************************************************