Datagrid - failure of dgHilitedLine / dgHilitedIndex

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Datagrid - failure of dgHilitedLine / dgHilitedIndex

Post by Simon Knight » Fri Jan 02, 2015 9:29 am

Hi,
I am trying to use a datagrid form for the first time to display some data held in a TSV file. I am at the stage where I would like to be able to edit the data held in certain "fields" and have found a tutorial named "How can the user edit field content in a Data Grid Form?".

The tutorial calls for a new handler to be added to "## Placed in script of row template behavior" which I take to mean the script that is opened when the button "Row Behavior..." is pressed in the object inspector.

Two versions of a mousedown handler are listed, the first extracts the dgHilitedLine the second the dgHilitedIndex. for purposes of experimentation and testing I have merged these two examples in to this handler which is in the Row Behavior:

Code: Select all

On mouseDown pBtnNum
   if pBtnNum is 1 then
      if the short name of the target is "Title" then
         put "Title" into theKey
         put the dgHilitedIndex of me into theIndex
         put the dgHilitedLine of me into theLineNo
         answer "Mouse up fires, the index is : " & theIndex & " The Line number is : " & theLineNo
         -- EditKey thekey, theLineNo
         -- EditKeyOfIndex theKey, theIndex
      end if
   end if
end mouseDown
The handler is being called but neither of the variables "theIndex" or "theLineNo" is being populated. Obviously I have made an error, do you have any ideas where?

best wishes

Simon K
best wishes
Skids

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: Datagrid - failure of dgHilitedLine / dgHilitedIndex

Post by sritcp » Fri Jan 02, 2015 7:40 pm

Hi Simon:

If you are using "on mouseDown", then try retrieving "the dgLine" rather than "the dgHilitedLine".
The highlighting of the line may not happen until the mouse is released.

Alternatively, use "on mouseUp" to retrieve "the dgHilitedindex", etc.

Regards,
Sri.

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Datagrid - failure of dgHilitedLine / dgHilitedIndex

Post by Simon Knight » Fri Jan 02, 2015 10:55 pm

Sri,

Thanks for spotting my silly mistake!

best wishes

Simon K
best wishes
Skids

Post Reply