How to programmatically select a datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to programmatically select a datagrid
HI all,
I have three dg's on a card. I can select a dg by clicking on it and then using up and down arrows to select a line. But, I want to enable the user to use the keyboard instead of the mouse. Is it possible to programmatically 'click' on the dg to enable the user to use the up and down keys ?
I have three dg's on a card. I can select a dg by clicking on it and then using up and down arrows to select a line. But, I want to enable the user to use the keyboard instead of the mouse. Is it possible to programmatically 'click' on the dg to enable the user to use the up and down keys ?
Re: How to programmatically select a datagrid
Hi,
You could.
That would focus on the DG you want. But once you get there, how do you navigate to the "cell" or row you are interested in? Something like:
That will at least get you to the second row. I bet if you played around a bit, you could get to a particular field, in the same way as if you double-clicked on that field.
Obviously I am no expert with DG's, though I do use them now and then.
Craig
You could
Code: Select all
click at the loc of grp "yourDatagrid".
That would focus on the DG you want. But once you get there, how do you navigate to the "cell" or row you are interested in? Something like:
Code: Select all
click at the loc of fld "col 1 0002" of grp "yourDatagrid"
click at the loc of fld "col 1 0002" of grp "yourDatagrid"
Obviously I am no expert with DG's, though I do use them now and then.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to programmatically select a datagrid
See the dgHilitedLines property.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to programmatically select a datagrid
Many thanks.
Re: How to programmatically select a datagrid
Richard.
A problem. Although something like:works fine, it does not "select" the DG itself.That means that the arrowKeys are not able to do any navigation. Clicking on a line in the DG does.
Craig
A problem. Although something like:
Code: Select all
set the DGHilitedLines of grp 1 to 3
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to programmatically select a datagrid
If he doesn't want the user to have to click on an object he wants to have focus, he'll have to handle events at the card or stack level and set the focus in response to the arrow key handler there.dunbarx wrote: ↑Wed May 14, 2025 1:48 pmRichard.
A problem. Although something like:works fine, it does not "select" the DG itself.That means that the arrowKeys are not able to do any navigation. Clicking on a line in the DG does.Code: Select all
set the DGHilitedLines of grp 1 to 3
The focus can be set with the "focus" command.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to programmatically select a datagrid
Richard.
Setting the focus of a DG does not, er, focus it. In fact, if I have a card with a single field, focussing on it:
does not do what the dictionary says it does, which to, er, focus on it and place a blinking cursor there. I have to click on the field to do that.
I never use the focus command. This may be a good reason to still not.
Craig
Setting the focus of a DG does not, er, focus it. In fact, if I have a card with a single field, focussing on it:
Code: Select all
focus on fld 1
I never use the focus command. This may be a good reason to still not.
Craig
Re: How to programmatically select a datagrid
AHA.
It does work from a button, just not from the message box. I see a short-lived "blink" in the fld from msg, but nothing changes.
Craig
It does work from a button, just not from the message box. I see a short-lived "blink" in the fld from msg, but nothing changes.
Craig
-
- Posts: 683
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: How to programmatically select a datagrid
Focusing and selecting are two different things.dunbarx wrote: ↑Wed May 14, 2025 5:13 pmRichard.
Setting the focus of a DG does not, er, focus it. In fact, if I have a card with a single field, focussing on it:does not do what the dictionary says it does, which to, er, focus on it and place a blinking cursor there. I have to click on the field to do that.Code: Select all
focus on fld 1
I never use the focus command. This may be a good reason to still not.
Craig
I usually do this as a combo something like:
Code: Select all
focus on fld 1
select char -1 to -1 of fld 1
Code: Select all
select line 1 of fld 1
-
- Posts: 683
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: How to programmatically select a datagrid
I definitely have a working example somewhere, of a Datagrid that's entirely navigable from a keyboard, arrowKeys, tabKey etc. I'll try to dig it out and post it if I get a minute.