datagrid form edit field

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

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

datagrid form edit field

Post by drunblut » Mon Nov 08, 2021 10:03 am

Hi,

in my datagrid form i have some editable fields. if i focus on one of these fields, the former content of the field should be cleared and the opaque of the background should be false. To delete the content works fine with

Code: Select all

put empty into fld "myfld" of me
in the mousedoubleup handler of the button behavior script of my datagrid. But

Code: Select all

set the opaque of fld "myfld" of me
doesn't work. The backgroundcolor remains white. Thanks for some help.

Grets Andreas

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: datagrid form edit field

Post by dunbarx » Mon Nov 08, 2021 3:00 pm

Hi.
set the opaque of fld "myfld" of me
In parlance, one can "set" a boolean. But in LiveCode, you have to go the extra mile:

Code: Select all

set the opaque of fld "myfld" of me to "true"
Craig

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: datagrid form edit field

Post by drunblut » Mon Nov 08, 2021 3:05 pm

sorry the second snippet is

Code: Select all

set the opaque of fld "myfld" of me to false

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: datagrid form edit field

Post by drunblut » Mon Nov 08, 2021 3:15 pm

Hi Craig,

sorry, i didn't read your reply before my last post. My second snippet is

Code: Select all

set the opaque of fld "myfld" of me to false
. But the backgroundcolor remains white.

Grets Andreas

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: datagrid form edit field

Post by jacque » Tue Nov 09, 2021 6:27 pm

Is it still visibly opaque? Opacity and color are separate properties, so the color can still be white but you shouldn't see it if the field is transparent.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: datagrid form edit field

Post by drunblut » Fri Nov 12, 2021 11:58 am

Hi Jacque,

when the card opens the opaque of the datagrid form with all fields is opaque as it should be. When i focus in an editable field, the opaque of this field changes and the backgroundcolor is white, but it should remain opaque. Maybe i must try it with

Code: Select all

set the script of button "Custom Field Editor Behavior" to the script of the behavior of button "Field Editor" of stack "revDataGridLibrary"
,

but i didn't understand how to do that.

Grets Andreas

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: datagrid form edit field

Post by dunbarx » Fri Nov 12, 2021 6:08 pm

drunblut

The actual fields in a dataGrid do not actually get focus. When you double click on one, and that field might be named "Col 1 0004" (you can see how this is laid out) in actuality, a "phantom" field named "datGridFieldEditor" is placed over the one you clicked on. It is that field that has focus.

The properties of that overlying field may be the source of your issues.

Craig

stam
Posts: 3064
Joined: Sun Jun 04, 2006 9:39 pm

Re: datagrid form edit field

Post by stam » Fri Nov 12, 2021 6:59 pm

dunbarx wrote:
Fri Nov 12, 2021 6:08 pm
drunblut

The actual fields in a dataGrid do not actually get focus. When you double click on one, and that field might be named "Col 1 0004" (you can see how this is laid out) in actuality, a "phantom" field named "datGridFieldEditor" is placed over the one you clicked on. It is that field that has focus.

The properties of that overlying field may be the source of your issues.

Craig
Can you intercept the field before it's shown and change it's opacity at runtime?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: datagrid form edit field

Post by dunbarx » Fri Nov 12, 2021 11:46 pm

I have never had much luck intercepting messages generated in a DG. They are mostly trapped within that gadget. So such juicy possibilities as "focusIn", "newField" or "mouseDoubleUp", all of which are generated when one double-clicks on a DG field, are trapped inside (though visible in the message watcher) and cannot be exploited.

Maybe one could test for the presence of the "datGridFieldEditor" field? There is no doubt that before one clicks on a field in a DG, there are a certain number of fields in the DG. But after the double click, there is one additional. So the "datGridFieldEditor" field is created by that action, and deleted when the user exits.

Trevor may not want people hacking his DG. But if he is reading this, maybe he will chime in.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: datagrid form edit field

Post by dunbarx » Sat Nov 13, 2021 12:07 am

In a small DG, three rows with three columns, there are 21 fields. If I make a button somewhere, with this in its script:

Code: Select all

on mouseEenter
   repeat with y = 1 to the number of flds
      put the name of fld y into line y of temp
   end repeat
   breakpoint
end mouseEnter
The debugger shows 21 fields in temp. If I then double click, to create the the "datGridFieldEditor" field, and move the cursor into the button, that field shows up as field 19 of 22. It pops up above the three "headerLabel" fields. Maybe it always appears above those.

Anyway, it just goes to show that a DG is just a LiveCode gadget, an impressive one, and to do what the OP wants is therefore certainly possible, but not necessarily straightforward.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: datagrid form edit field

Post by dunbarx » Sat Nov 13, 2021 12:21 am

OK. I still have my 3-column/3-row DG and that button. But now in the button script:

Code: Select all

on mouseenter
   repeat with y = 1 to the number of flds
      put the name of fld y into line y of temp
   end repeat
   set the backColor of  field 19 to "red"
end mouseenter
Double-click any field, and immediately move the cursor into the button. The field "datGridFieldEditor" changes to red. This is not the underlying "cell" in the DG. The red does not stick, since the field "datGridFieldEditor" does not either.

Craig
Last edited by dunbarx on Sat Nov 13, 2021 12:33 am, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: datagrid form edit field

Post by dunbarx » Sat Nov 13, 2021 12:27 am

Getting like Richmond here with all these successive posts.

On the same setup, this in the group script:

Code: Select all

on mouseEnter
   put the target
 if the optionKey is down then set the backColor the target to any item of "red,green,yellow,blue"
end mouseEnter
Moving the cursor around shows the actual DG field one enters in real time. But holding the optionKey down changes color, all right, but not of the field, rather of the entire DG field area. And not if you move within the actual data area. The color only changes when I move below the data area into blank space.

So much fun...


Craig

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: datagrid form edit field

Post by drunblut » Mon Nov 15, 2021 10:59 am

Hi,
thanks for your replies. I did tried

Code: Select all

set the opaque of fld "datGridFieldEditor" of me to false
That doesn't work either (object not found).

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: datagrid form edit field

Post by jacque » Mon Nov 15, 2021 7:08 pm

It sounds like the data entry field is created on the fly as needed, since it isn't found when it isn't visible. A variation of Dunbar's mouseEnter handler might work. Check the name of the target and if it's "dataGridFieldEditor" then set its opaque property.

Edit: I just noticed you misspelled dataGridFieldEditor (you have datGridFieldEditor) so correcting that may fix the problem.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: datagrid form edit field

Post by dunbarx » Mon Nov 15, 2021 7:23 pm

set the opaque of fld "datGridFieldEditor" of me to false
That field is ephemeral. It is hard to pin down, because it likes very much to go away at the slightest provocation. It is the permanent underlying fields that comprise the actual DG you are interested in. But these are mollycoddled by the DG itself. For example, the following handlers ought to cause a flurry of changing colors:

Code: Select all

on mouseEnter
   if the name of the target contains "Col" then 
      set the opaque of the target to "true"
      set the backColor of the target to any item of "green,blue,yellow,red,orange"
    end if
   end mouseEnter
   
on mouseLeave
   if the target contains "Col" then
      set the opaque of the target to "false"
      set the backColor of the target to ""
   end if
end mouseLeave
But it does not (though it would with a bunch of controls just sitting on the card) because those messages are already trapped within the group, and not passed along. You might hack the DG, and add a "pass" command. Is it worth it?

Just to see. try this in the msg box:

Code: Select all

set the opaque of fld "Col 1 0001" to "true"
set the backColor of fld "Col 1 0001" to  any item of "green,blue,yellow,red,orange"
But now you have to already know the field of interest.

Craig

Post Reply