egrid 4 grid gadget - (static PB library version.)

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

In the #egrid_NotifyCellType message, assuming you've declared the checkbox type cell with something like:

Code: Select all

*cellinfo\celltype=#egrid_CheckBox
*cellinfo\text="TRUE/FALSE"
(you can use any values in place of TRUE/FALSE; e.g. "YES/NO" etc.)

then the following command:

Code: Select all

egrid_SetCellText(#egrid, col, row, "TRUE")
will check the (col, row) cell's checkbox etc.

Is this what you're after?
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

No :)
If the user change the state of checkbox, without selecting, only click on
checkbox, i will have this event in cellcallback.

like #egrid_CellButtonClick, but for checkbox.

Code: Select all

#egrid_CellUpdated
#egrid_InsertChar
#egrid_SelectCell
doesn't do this for me
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Right, if I now understand correctly, you wish to be notified when the user clicks to change the checkmark (from true to false for example) but does not select the cell?

Am I correct? :)
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

srod wrote: Am I correct? :)
Your are correct, ever :wink:
but my english is badly :lol:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You can certainly do this with the #egrid_CellUpdated message. It fires whenever the user alters a checkmark when the cell is not selected.

If the cell is already selected then the message will fire when focus moves to another cell.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

merihevonen wrote:This is really a wonderful project btw.
Thanks. :)
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

srod wrote:You can certainly do this with the #egrid_CellUpdated message. It fires whenever the user alters a checkmark when the cell is not selected.

If the cell is already selected then the message will fire when focus moves to another cell.

Code: Select all

    Case #egrid_CellUpdated
      result = #True
      If CountSelected() <> Count
        Count = CountSelected()
        SetWindowTitle(0, "Lib2PBImport - " + LibName + "     [" + Str(CountSelected()) + " of " + Str(egrid_NumberOfRows(#egrid)) + " Functions selected]")
      EndIf
doesn't work :cry:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

All I can say is that I'm sitting here with a quickly bashed up example which works fine!

I can't comment upon the contents of your #egrid_CellUpdated handler, but you can at least test out if the message is firing by placing a messagerequester immediately after the case #egrid_CellUpdated command etc.

I'll pm you.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

here the CountSelected()

Code: Select all

Procedure CountSelected()
  Protected i.l, count.l
  For i = 0 To egrid_NumberOfRows(#egrid) -1
    If egrid_GetCellText(#egrid, 0, i) = "TRUE"
      count + 1
    EndIf
  Next
  ProcedureReturn count
EndProcedure
count is a static variable
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I catch that event in a couple of my apps, I cut the snippet from one:

Code: Select all

  If message = #WM_NOTIFY 
    *ptr.NMHDR = lParam 
    If *ptr\HwndFrom = GadgetID(#List_1) 
      Select *ptr\code 
        Case #LVN_ITEMCHANGED 
          MyChangeEvent(#True) 
fires on a checkmark change, dunno if it helps you or not.
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

@ts-soft: here's the problem. When the #egrid_CellUpdated message fires, the cell that has just been clicked has NOT had it's contents physically changed. This gives the developer the chance to refuse the alteration etc.

So, what you'll need to do is, for the cell which has just been clicked, rather than use egrid_GetCellText() (which will contain the old value) simply examine the value of *cellinfo\text instead; this contains the new contents if you allow the alteration to proceed.


The sequence is as follows: (imagine cell (0, 0) is a checkbox which currently holds the value "FALSE")
  • User clicks the checkmark in cell (0, 0)
  • The #egrid_CellUpdated message fires. Cell (0, 0) still contains the value "FALSE", but *cellinfo\text contains "TRUE"
  • You call your CountSelected() procedure.
  • Return control to egrid which only now changes cell (0, 0) to "TRUE" (unless you've refused the change).
Hope this helps.

:)
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

netmaestro wrote:I catch that event in a couple of my apps, I cut the snippet from one:

Code: Select all

  If message = #WM_NOTIFY 
    *ptr.NMHDR = lParam 
    If *ptr\HwndFrom = GadgetID(#List_1) 
      Select *ptr\code 
        Case #LVN_ITEMCHANGED 
          MyChangeEvent(#True) 
fires on a checkmark change, dunno if it helps you or not.
This message will not work as it is with an egrid because the underlying cell of the listicon is not always kept up to date with what is going on in the edit controls / comboboxes etc. (in fact there are no actual checkbox controls as egrid simulates these).
This was done to combat flickering etc.

This is all dealt with by egrid.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

thanks, it works :D
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

That's great. We got there in the end! :)
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

srod wrote:That's great. We got there in the end! :)
The next problem, if the checkbox is selected, i become no changes :cry:
I'm tested all, but nothing fires this event.
I hope, you can give me a tip :)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply