Add a behavior to a datagrid group ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ZoOoOoP
Posts: 10
Joined: Sun Feb 27, 2022 2:17 pm

Add a behavior to a datagrid group ?

Post by ZoOoOoP » Sun Feb 27, 2022 2:23 pm

Hello, there is a solution to add a behavior to a datagrid group ?

(no column behavior, or header behavior, but a general behavior like all other groups/buttons/etc...)

Thank you =)

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Add a behavior to a datagrid group ?

Post by Klaus » Sun Feb 27, 2022 2:48 pm

Hi ZoOoOop,

welcome to the forum!

Sure this is possible, you can assign a behavior to every LC object.
If it will make sense is another question. A datagrid is a complex beast! :-)

Best

Klaus

ZoOoOoP
Posts: 10
Joined: Sun Feb 27, 2022 2:17 pm

Re: Add a behavior to a datagrid group ?

Post by ZoOoOoP » Sun Feb 27, 2022 3:31 pm

Thank you for answer but for example in any "normal group" i have it but not in "datagrid group" (see attachments)
Attachments
yes.jpg
nop.jpg

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Add a behavior to a datagrid group ?

Post by Klaus » Sun Feb 27, 2022 3:44 pm

Ah, OK, obviously not via the inspector, but works fine via message box:

Code: Select all

set the behavior of grp 1 to the long ID of btn 1
Tested and works! :D
Will however completely overwrite the "normal" datagrid behavior!

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Add a behavior to a datagrid group ?

Post by Klaus » Sun Feb 27, 2022 3:57 pm

But we can use nested behaviors with the datagrid, check a demo on Github:
https://github.com/bwmilby/lc-misc
Hope that helps.

ZoOoOoP
Posts: 10
Joined: Sun Feb 27, 2022 2:17 pm

Re: Add a behavior to a datagrid group ?

Post by ZoOoOoP » Sun Feb 27, 2022 5:22 pm

Klaus wrote:
Sun Feb 27, 2022 3:44 pm
Ah, OK, obviously not via the inspector, but works fine via message box:

Code: Select all

set the behavior of grp 1 to the long ID of btn 1
Tested and works! :D
Will however completely overwrite the "normal" datagrid behavior!
I succeed to change behavior like this OK, but :

On my data grid -> "put the behavior of group "DG_MYGRID" -> button id 1005 of stack "revDataGridLibrary"

put the behavior of button id 1005 of stack "revDataGridLibrary" -> stack "RevDataGridLibraryBehaviorsDataGridButtonBehavior"

Even if i add ["button id 1005 of stack "revDataGridLibrary"] or [stack "RevDataGridLibraryBehaviorsDataGridButtonBehavior"] in my new empty button behavior, the data grid don't work yet...

I will go to see your link now.
(edit : it's exactly that i try to do, i will debug with that to see where i'm wrong)

ZoOoOoP
Posts: 10
Joined: Sun Feb 27, 2022 2:17 pm

Re: Add a behavior to a datagrid group ?

Post by ZoOoOoP » Sun Feb 27, 2022 5:42 pm

Klaus wrote:
Sun Feb 27, 2022 3:57 pm
But we can use nested behaviors with the datagrid, check a demo on Github:
Hope that helps.
Thank you for help all is working now =)

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Add a behavior to a datagrid group ?

Post by Klaus » Sun Feb 27, 2022 6:17 pm

Great!

May I ask what special behavior you added to your datagrid?

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Add a behavior to a datagrid group ?

Post by stam » Sun Feb 27, 2022 6:47 pm

Actually that’s interesting.
I have a bunch of data grids with semi-translucent scroll bars that hide with a swift transition when the scrolling stops, and reappear and can be dragged when the scrolling starts.

I’ve had to put that code within each individual DG as you can’t really subclass stuff, would be a lot handier if this could be set as a behaviour… will definitely look into this!

ZoOoOoP
Posts: 10
Joined: Sun Feb 27, 2022 2:17 pm

Re: Add a behavior to a datagrid group ?

Post by ZoOoOoP » Sun Feb 27, 2022 8:20 pm

Klaus wrote:
Sun Feb 27, 2022 6:17 pm
Great!

May I ask what special behavior you added to your datagrid?
I just realize it was the opened in memory "NestedDGBehavior" who make it works :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”