Trapping keystrokes outside Datagrid interfering with DG Field Editor

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

adxsoft
Posts: 26
Joined: Wed Apr 11, 2018 12:25 pm

Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by adxsoft » Sat Apr 11, 2020 3:33 am

I have a keyUp handler in my datagrid group script which detects letter "A" and has code that will format the current row in my datagrid (on the same card). The keyUp handler performs some simple actions when letter "A" is detected.

DataGrid script

Code: Select all

on keyUp pKey
   if pKey is "A" then
      # do something, for example
      put the dgHilitedLines of group "MyGrid" into tLineNo
      put the dgDataOfLine[the dgHilitedLines of grp "MyGrid"] of grp "MyCard" into tArray
      put "SomeValue" into tArray["Date"
      dispatch "ResetList" to grp "MyGrid" 
      set the dgHilitedLines of grp "MyGrid" to tLineNo
   end if
   pass keyUp
end keyUp
This works fine however when I double click a field in the grid and type the letter "A" then the keyUp handler processes the A whereas I want it to let the A through without doing anything.

My thought is to have the keyUp handler somehow be aware that a field edit is in progress however I cannot find a way to detect this.

Any tips would be greatly appreciated.

I'm using LC9.5.1 on Mac.

Cheers
Allan

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by richmond62 » Sat Apr 11, 2020 8:48 am

Well, how about something like this . . .

Script in datagrid:

Code: Select all

on keyDown
pass keyUp
----blah, blah, blah
end keyDown
that should mean that you can then type into the grid.
-
Screenshot 2020-04-11 at 10.54.19.png
Screenshot 2020-04-11 at 10.54.19.png (12.13 KiB) Viewed 11641 times
-
Nope!

HOWEVER . . . I have just set up a stack containing a single field with this code in the cardScript:

Code: Select all

on keyUp KUP
   put "%" && KUP && "%" into fld "ff"
end keyUp
and this in the fieldScript:

Code: Select all

on keyUp KAP
   put KAP into me
end keyUp
And when I type in the field the fieldScript over-rides the cardScript.

The stack is here: https://www.dropbox.com/s/7npu3b67e7h7u ... e.zip?dl=0

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by Klaus » Sat Apr 11, 2020 9:46 am

on keyDown
pass keyUp
...
You really should get some (more) sleep! 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by richmond62 » Sat Apr 11, 2020 11:41 am

You really should get some (more) sleep! 8)
No: I should just wait until after my morning cup of coffee. 8)

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by Klaus » Sat Apr 11, 2020 12:02 pm

Or that. :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by richmond62 » Sat Apr 11, 2020 3:45 pm

Of course there is a point of view that states that attempting to help an OP is better than making sarcastic remarks.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by Klaus » Sat Apr 11, 2020 3:55 pm

Yes, sure, but take a look at your first posting, especially the screenshot and the line below!
I just could not help but add this remark! 8)

Sorry, Allan!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by richmond62 » Sat Apr 11, 2020 4:05 pm

Sometimes I write as I think as I do.

This does have the advantage that no-one else is going to make the goofy mistakes they have already seen me make!

And the fact that the script of the first control that gets a mouseClick will over-ride any of the same "higher up the tree"
is worth noticing . . .

While you may inherit your father's wise looks, your foolishness over-rides that. 8)
Last edited by richmond62 on Sat Apr 11, 2020 4:40 pm, edited 1 time in total.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by Klaus » Sat Apr 11, 2020 4:19 pm

Not sure if the last line is just a saying or an insult! :D

@Allan
Sorry for our little verbal exchange!
Ok, after a bit of reading, do this, tested and works:

Code: Select all

on keyUp pKey
  ## We just sort out the Field Editor!
  if the short name of the target = "DataGridFieldEditor" then
      pass keyup
   end if

   if pKey is "A" then
      # do something, for example
      put the dgHilitedLines of group "MyGrid" into tLineNo
      put the dgDataOfLine[the dgHilitedLines of grp "MyGrid"] of grp "MyCard" into tArray
      put "SomeValue" into tArray["Date"
      dispatch "ResetList" to grp "MyGrid" 
      set the dgHilitedLines of grp "MyGrid" to tLineNo
   end if
   pass keyUp
end keyUp
So Richmond cannot accuse me of only writing bitchy remarks anymore! :-D

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by bogs » Sat Apr 11, 2020 4:33 pm

Klaus wrote:
Sat Apr 11, 2020 4:19 pm
So Richmond cannot accuse me of only writing bitchy remarks anymore!
When I wake up later, I'll make sure to laugh at that one ... nah, why wait? Image
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by richmond62 » Sat Apr 11, 2020 4:42 pm

Klaus wrote:
Sat Apr 11, 2020 4:19 pm
So Richmond cannot accuse me of only writing bitchy remarks anymore! :-D
I have never accused you of ONLY writing bitchy remarks. 8)

And if
While you may inherit your father's wise looks, your foolishness over-rides that.
is an insult, it applies to me for starters. :)

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by Klaus » Sat Apr 11, 2020 4:56 pm

bogs wrote:
Sat Apr 11, 2020 4:33 pm
Klaus wrote:
Sat Apr 11, 2020 4:19 pm
So Richmond cannot accuse me of only writing bitchy remarks anymore!
When I wake up later, I'll make sure to laugh at that one ... nah, why wait? Image
:D :D :D

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by Klaus » Sat Apr 11, 2020 4:59 pm

richmond62 wrote:
Sat Apr 11, 2020 4:42 pm
Klaus wrote:
Sat Apr 11, 2020 4:19 pm
So Richmond cannot accuse me of only writing bitchy remarks anymore! :-D
I have never accused you of ONLY writing bitchy remarks. 8)
Sorry, forgot to mention "... in this thread!" :D

BTW: Happy Easter!
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by richmond62 » Sat Apr 11, 2020 6:34 pm

Not round this neck of the woods: our Easter is next week.

If this is a conceptual problem for you go and check out the Latin word fileoque . . . 8)

Not that, frankly I believe 'God' is either a sectarian, or a supporter of most of organised religion.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Trapping keystrokes outside Datagrid interfering with DG Field Editor

Post by bogs » Sat Apr 11, 2020 6:40 pm

Don't look at me, I only believe in the Flying Sphagetti Monster.
Image
Image

Post Reply