DataGrid mouseover selecting

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
massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

DataGrid mouseover selecting

Post by massung » Mon Nov 23, 2009 5:08 pm

I'll describe the effect that I want and hopefully someone here can point me to the code to modify or has some ideas for me. I've tried several things so far to no avail...

I have a DataGrid form, where each entry has a bunch of text, and some buttons. With every entry displaying all their buttons, it looks extremely cluttered and difficult to use. What I want to do is have the buttons only be visible on the item that actually matters at the moment.

The above is actually very easy to do if the "auto hilite" property of the DataGrid is set to true, because I'll get the dgHilite setprop call, and I can hide or show the buttons based on the pBoolean value passed in. But, I don't want to set this to true. Instead, I'd rather just use mouseMove and hide/show the buttons immediately based on which entry the user is looking at. Also, I don't want to hilite the selected form row for various reasons that are important and I'd rather not get into.

Now, I've tried using mouseEnter and similar events within the row template for the form, but none of those events seem to trigger. If I knew where dgHilite was getting called from I'd add some more code in there to possibly do what I want. Or perhaps there's another way that's better.

Ideas anyone?

Thanks!

Jeff M.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: DataGrid mouseover selecting

Post by sturgis » Mon Nov 23, 2009 11:49 pm

Its possible to do what you want relatively easily. I have a stack that has a "disclosure" button that shows rows when you click them. Its pretty easy to modify things to work with mouseEnter however, the grid can be a little ill mannered when using mouseEnter since the row itself changes size based in where the mouse is.

My current setup is with a disclosure button system.

Code: Select all

  if the short name of the target is "discloseButton" then
         put the dgControl of me into theDataGrid
         put the dgLine of me into theLine
         put the dgDataOfLine[theLine] of theDataGrid into tDataA
         put not tDataA["Expanded"] into tDataA["Expanded"]
         set the dgDataOfLine[theLine] of theDataGrid to tDataA
      end if
All this does is change the flag for whether the row is expanded, then resets the data line for that row to the adjusted value. At this point, the handlers to fill in data and lay it out are called, so the line is rebuilt using the new flag.

In fillIndata I have:

Code: Select all

set the visible of group "entryGroup" of me to theDataA["Expanded"]
   set the visible of button "answerButton" of me to theDataA["Expanded"]
The row heights are set to non-fixed, so this adjusts the line height dynamically based on the visibility of whether my entryGroup is hidden or not.

If you want to always have only 1 row expanded the code can be modified as such:

Code: Select all

 if the short name of the target is "discloseButton" then
         put the dgControl of me into theDataGrid
         put the dgLine of me into theLine
         put the dgDataOfLine[theLine] of theDataGrid into tDataA
         put true into tDataA["Expanded"]
if lastLine is not empty then
      put the dgDataOfLine[lastLine] of theDataGrid into lastDataA
      put false into lastDataA["Expanded"]
      set the dgDataOfLine[lastLine] of theDataGrid to lastDataA
   end if
   put theLine into lastLIne
         set the dgDataOfLine[theLine] of theDataGrid to tDataA
      end if
lastLine will need to be declared so that it persists, can make it global at the top of the behavior script, should work if you declare it as local at the top instead I believe.

I haven't specifically tested this code, but it should be close to a method that could work. I haven't thought it all through for example, I doubt it will behave as you wish if you keep clicking the same disclosure button, but hopefully will get you over the hump.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: DataGrid mouseover selecting

Post by sturgis » Tue Nov 24, 2009 1:35 am

Heres the same thing (a little improved) Using mouseEnter. As mentioned above, its behaves badly due to the way the rows change size (if your row size is static this won't matter) But i'm still new enough at this stuff I haven't figured out a workaround yet.

Code: Select all

on mouseEnter
   put the dgControl of me into theDataGrid
   put the dgLine of me into theLine
   put the dgDataOfLine[theLine] of theDataGrid into tDataA
   put not tDataA["Expanded"] into tDataA["Expanded"]
   if lastLine is not empty and lastLine <> theLine then
      put the dgDataOfLine[lastLine] of theDataGrid into theLastA
      put false into theLastA["Expanded"]
      set the dgDataOfLine[lastLine] of theDataGrid to theLastA
      set the dgDataOfLine[theLine] of theDataGrid to tDataA
      put theLine into lastLine
   else if lastLine is not empty and lastLine = theLine then
      set the dgDataOfLine[theLine] of theDataGrid to tDataA
      
   end if
end mouseEnter

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: DataGrid mouseover selecting

Post by trevordevore » Tue Nov 24, 2009 2:36 pm

You should get all events (i.e. mouseEnter) as long as you have a visible, enabled control showing in your Data Grid column. Is it possible that by hiding the controls in the columns that there are no controls to receive the events?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply