Page 1 of 1

DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 4:17 am
by newpie
Hello, I was wondering how to achieve making a text field auto scroll (like a stock ticker) when user clicks on particular DataGrid field. I can get the first row to work, but cannot specify further rows as it just triggers first row again. I am testing with animation engine.

On Card Script:

Code: Select all

on autoScroll pStart,pDuration
   lock screen   local tScroll,tElapsed
   put the millisecs-pStart into tElapsed
   put round(aeEaseIn(0,the formattedWidth fld "fieldName",pDuration,tElapsed,2)) into tScroll
   set the hScroll of fld "fieldName" to tScroll
   unlock screen
   if tElapsed < pDuration then
      send "autoScroll" && pStart,pDuration to me in 30 millisecs
   end if
end autoScroll
On Behavior Script

Code: Select all

on mouseUp pMouseBtnNum 
   
if pMouseBtnNum is 1 then
      switch the short name of the target   
         case "fieldName"
            autoScroll the millisecs,12000
            break       
      end switch
   end if
   pass mouseUp
end mouseUp
I tried using target gathering techniques like "the long ID of the target", but get Chunk errors.

Any help would be great, thanks

Happy Holidays

Re: DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 1:16 pm
by Klaus
Hi newpie,

maybe I am overlooking something, but I don't see any relation between:
clicked field in datagrid <-> scroll of your field?

You only handle ONE field in your mouseup handler.


Best

Klaus

Re: DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 5:11 pm
by newpie
Hey Klaus, yes it only specifies one field. I tried to target it but unsure how to specify the particular field row. I tried the following below, but get an error.

1. Used

Code: Select all

put the long id of the target into pTargetField
on behavior script and tried to pass as a parameter on the card script

Code: Select all

on autoScroll pStart,pDuration,pTargetField
, then I replace

Code: Select all

fld "fieldName"
with pTargetField in the body of the code.

The error I receive is
card "card1": execution error at line 268 (Chunk: error in object expression) near "fieldName", char 44
Is there a way to make it target without error?

Re: DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 5:21 pm
by Klaus
Still don't get it!? So you want so (H)scroll a field in the datagrid?

Is this a datagrid of type TABLE or FORM?
Just make a quick test with a new dg of type TABLE with this script (in the group script, no behaviour):

Code: Select all

on mouseup
   put the long ID of the target
end mouseup
And got in the message box what I exspected like:
field id 1065 of group id 1041 of group id 1013 of group id 1011 of group id 1004 of card id 1002 of stack "Stack 1451751708"

But I still don't see any relation between: field/column clicked in datagrid <-> scroll of you OTHER text field as described in your initial posting!?
What is the difference between clicking e.g "Field1" vs "Field44"?

Maybe you can provide a screenshot, I am completely lost... :D

Re: DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 5:44 pm
by newpie
Hey Klaus, thank you for the fast response. I am working with a FORM. Sorry for the confusion, let me try to explain differently. The "put the long id of the target into pTargetField" works great actually in the behavior script, but the card script gives me error when I try to use it.

My main goal: When the user clicks on a certain field (built in the row template) then it will auto-scroll the text of that field (many characters that don't fit in that field) from left to right so the user can see all data in that field.

Situation:
1. I input two records Row 1 and Row 2 with following data.
Row 1 fieldName has = This is a long sentence that the user may read but cannot see the entire sentence.
Row 2 fieldName has = Another bunch of words that the user wants to see in this field and I would like to show with scroll.

2a. When I click row 2 with this code row 1 will autoscroll only. Which I agree with you as it doesn't specify the row.

Code: Select all

    on autoScroll pStart,pDuration
       lock screen   local tScroll,tElapsed
       put the millisecs-pStart into tElapsed
       put round(aeEaseIn(0,the formattedWidth fld "fieldName",pDuration,tElapsed,2)) into tScroll
       set the hScroll of fld "fieldName" to tScroll
       unlock screen
       if tElapsed < pDuration then
          send "autoScroll" && pStart,pDuration to me in 30 millisecs
       end if
    end autoScroll
2b.When I click row 2 with this code (as I modified the behavior script to pass the parameter) I get the error card "card1": execution error at line 268 (Chunk: error in object expression) near "fieldName", char 44

Code: Select all

    on autoScroll pStart,pDuration
       lock screen   local tScroll,tElapsed
       put the millisecs-pStart into tElapsed
       put round(aeEaseIn(0,the formattedWidth pTargetField ,pDuration,tElapsed,2)) into tScroll
       set the hScroll of pTargetField to tScroll
       unlock screen
       if tElapsed < pDuration then
          send "autoScroll" && pStart,pDuration to me in 30 millisecs
       end if
    end autoScroll
Your question:
But I still don't see any relation between: field/column clicked in datagrid <-> scroll of you OTHER text field as described in your initial posting!?
What is the difference between clicking e.g "Field1" vs "Field44"?
Hopefully I explained the difference above, basically I am unsure on how to make the card script handler act only on the field I click on. So in your example, if I click Field4 only Field1 would autoscroll.

Thanks

Re: DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 6:28 pm
by Klaus
AHA, now we're talking! :D

OK, I see a syntax error in this line:
...
## put round(aeEaseIn(0,the formattedWidth pTargetField ,pDuration,tElapsed,2)) into tScroll
...
Should read:
...
put round(aeEaseIn(0,the formattedWidth OF pTargetField ,pDuration,tElapsed,2)) into tScroll
...
But that should not be the problem...

You DID declare pTargetField as LOCAL or GLOBAL, did you?
If NOT I'm afraid I have to bill you 5 Euro! 8)


Best

Klaus

Re: DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 6:51 pm
by newpie
Great! I didn't think I would need a global as I was going to pass a parameter to the handler, but when I tried that it still gave me "chunk error". I am not sure how to get the parameter to work so I went with the global method instead. As long it works is great. I will play with the parameter thing when I have time.

thanks for your help

Re: DataGrid Scrolling - how to target specifc field

Posted: Sat Jan 02, 2016 7:40 pm
by Klaus
You're welcome!

But you obviously did not notice my last sentence!? :D

Re: DataGrid Scrolling - how to target specifc field

Posted: Sun Jan 03, 2016 6:31 pm
by jacque
newpie wrote:Great! I didn't think I would need a global as I was going to pass a parameter to the handler
That's the method I'd use rather than a global, but note you have to add the parameter to the receiving handler as well:

on autoScroll pStart,pDuration,pTargetfield