Little Arrows in Datagrid

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
ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Little Arrows in Datagrid

Post by ittarter » Tue Jul 18, 2017 11:32 pm

Hi all,

So something interesting is happening that forces LC to complete shut down!

I have a data grid form with little arrows (a form of scrollbar). I'm new to little arrows but discovered the message that is sent when the "increase" and "decrease" arrows are clicked. So, not knowing how that handler would trigger in a datagrid, I added this code to the group:

Code: Select all

on scrollbarLineDec
   answer the long name of me
end scrollbarLineDec
and discovered that it worked! I figured that it would be better to put the code somewhere else, but for the purposes of experimentation, I wanted to see the limits of what I could do in the script of the group itself. So I updated the handler to read:

Code: Select all

on scrollbarLineDec
   put the dgHilitedLines of me into tLine
   put the dgText of me into tData
   set the itemdel to tab
   put item 2 of line tLine of tData into x
   put x into item 2 of line tLine of tData
   set the dgText of me to tData
end scrollbarLineDec
The fillin of the behavior script reads:

Code: Select all

set the text of field "Text" of me to pDataArray["label 1"]
    set the text of field "Score" of me to pDataArray["label 2"]
The interesting thing is, when I click the little arrows of one of the data grid lines, LC attempts to draw the grid... And then tries to draw it again... And when it gets to the bottom line, LC crashes (no error message) and closes itself.

Any idea why?

Also, what is the proper place to put scrollbarLineDec and scrollbarLineInc in order to update the text of a different object in the same line? or is there a better way to do this?

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

Re: Little Arrows in Datagrid

Post by Klaus » Wed Jul 19, 2017 2:30 pm

Hi ittarter,

besides the fact that your "scrollbarLineDec" does nothing actually***, these little arrows are meant for de-/increasing values in a field like a "data" field or something.
I, personally, would not think of clicking a scrollbar (little arrows) to modify "other" data, that is a job for a BUTTON. :D

***put item 2 of line X of tData into item 2 of line X of tData ##??? :shock:

But no idea why this crahes LC, it definitively should NOT!
If this is reprocucable, please consider to create a bug report here: http://quality.livecode.com


Best

Klaus

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: Little Arrows in Datagrid

Post by ittarter » Wed Jul 19, 2017 8:00 pm

besides the fact that your "scrollbarLineDec" does nothing actually***, these little arrows are meant for de-/increasing values in a field like a "data" field or something.
I, personally, would not think of clicking a scrollbar (little arrows) to modify "other" data, that is a job for a BUTTON. :D
All I wanted to do was increase/decrease the value of a field with a single number in it, but yes, also to change the value of the data grid's array. I was thinking about trying buttons instead but the error was too interesting. I'm surprised that you say scrollbarLineDec does nothing, because when I click on the scrollbar little arrows if I place them directly on the card, it calls this handler automatically, and it's the easiest way to determine if the user clicked one or the other arrow.
***put item 2 of line X of tData into item 2 of line X of tData ##??? :shock:
Yeah, I took out a line of code where I was adding one to x, so now it looks strange :)
But no idea why this crahes LC, it definitively should NOT!
If this is reprocucable, please consider to create a bug report here: http://quality.livecode.com
OK will do.

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

Re: Little Arrows in Datagrid

Post by Klaus » Wed Jul 19, 2017 8:19 pm

ittarter wrote:...I'm surprised that you say scrollbarLineDec does nothing...
Sorry, I meant the script that you posted does nothing.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Little Arrows in Datagrid

Post by MaxV » Thu Jul 20, 2017 8:10 am

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Little Arrows in Datagrid

Post by MaxV » Thu Jul 20, 2017 1:09 pm

More over, just edit the colum, add the little arrow and use this code:

Code: Select all

on scrollbarLineDec
   put the long id of the owner of me into temp
   add 1 to field 1 of temp
end scrollbarLineDec

on ScrollbarLineInc
   put the long id of the owner of me into temp
   add -1 to field 1 of temp
end ScrollbarLineInc
It works great:
Image
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”