sending a Backspace to a on Keyup commnd
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: sending a Backspace to a on Keyup commnd
Hi Folks,
I do appreciate all of your responses to my question about sending the "BackSpaceKey"
Again, the suggestion that Richmond2 gave was the one that worked well for me,
I am sure that some of you might be curious about my need for such a bit of code.
If you are interested in seeing my sample of why I wanted this, I will post my sample LC application.
I await your response.
I do appreciate all of your responses to my question about sending the "BackSpaceKey"
Again, the suggestion that Richmond2 gave was the one that worked well for me,
I am sure that some of you might be curious about my need for such a bit of code.
If you are interested in seeing my sample of why I wanted this, I will post my sample LC application.
I await your response.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: sending a Backspace to a on Keyup commnd
Just to make things as simple as possible:
Works with LC 6/7/8/9.
Type sends rawkeydown and rawkeyup, so cannot be trapped by keydown/keyup.
Code: Select all
on mouseUp
select char 5 of fld 1 -- or whatever char
type numToChar(8)
end mouseUp
Type sends rawkeydown and rawkeyup, so cannot be trapped by keydown/keyup.
shiftLock happens
Re: sending a Backspace to a on Keyup commnd
That is pretty simple and slick, nice one -hh.
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: sending a Backspace to a on Keyup commnd
HH,
your script works also!
your script works also!
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: sending a Backspace to a on Keyup commnd
For anyone interested - here is my sample application.
It includes a US States file to load into the list.
Do with it whatever you want.
It is a drop list that is parsed by typing letters in the parsing field or clicking the down arrow to get a full list.
It includes a US States file to load into the list.
Do with it whatever you want.
It is a drop list that is parsed by typing letters in the parsing field or clicking the down arrow to get a full list.
- Attachments
-
- stateDropDownList.zip
- (3.17 KiB) Downloaded 220 times
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: sending a Backspace to a on Keyup commnd
Clarence,
this is a nice idea.
Recently I made a search field that uses a different approach ('textchanged') and has several styling features (highlights the found string).
It also searches for lines which contain the search string, like Hypercard's "find string".
So you can for example find "Kentucky" uniquely by typing one of ck,ke,ky,tu.
It is all self contained.
All you need is a search field, set text properties and the width of it.
Thereafter (not before) set the script of the search field as follows and click or type in it.
Just for fun (and giving more ideas).
this is a nice idea.
Recently I made a search field that uses a different approach ('textchanged') and has several styling features (highlights the found string).
It also searches for lines which contain the search string, like Hypercard's "find string".
So you can for example find "Kentucky" uniquely by typing one of ck,ke,ky,tu.
It is all self contained.
All you need is a search field, set text properties and the width of it.
Thereafter (not before) set the script of the search field as follows and click or type in it.
Just for fun (and giving more ideas).
Code: Select all
local sL0, ff="output"
on textchanged
lock screen; lock messages
put me into t
put length(t) into l
-- LC 6 has no "filter into", so:
put sL0 into sL
filter sL with ("*"&t&"*")
put the num of lines of sL into sN
if sN > 0 then
put sL into fld ff
if l>0 then
repeat with i=1 to sN
put offset(t,line i of sL)-1 into o1
set backcolor of char o1+1 to o1+l of line i \
of fld ff to "yellow"
end repeat
end if
else
put "Found nothing" into fld ff
set foreColor of char 1 to -1 of fld ff to "blue"
end if
setSize
end textchanged
on setSize
lock screen; lock messages
put the width of me into w
put the height of this card into h0
put h0 - the effective textheight of fld ff into h1
put h1 - the top of fld ff into h
put the formattedHeight of fld ff into fh
set vscrollbar of fld ff to (fh > h)
set height of fld ff to min(h,fh)
set width of fld ff to max(w,the formattedWidth of fld ff)
set topleft of fld ff to the botleft of me
end setSize
on openField -- get the statesList
set itemdel to "#"
put line 2 to -2 of (item 3 of the script of me) into sL0
if there is no fld ff then
lock screen; lock messages
clone me; put it into f
set name of f to ff
set listbehavior of f to true
set fixedLineHeight of f to true
set borderColor of f to "235,235,235" -- mercury
set hgrid of f to true
set topleft of f to the botleft of me
end if
textchanged
end openField
#--states list start
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming
#--states list end
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: sending a Backspace to a on Keyup commnd
The main thing that I like about LiveCode is its versatility.
L C offers so many ways to achieve a result, you just need imagination and problems will be solved.
Cool Stuff.
L C offers so many ways to achieve a result, you just need imagination and problems will be solved.
Cool Stuff.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: sending a Backspace to a on Keyup commnd
That's why, in my code above, I had to have 2 type signals so the first one wouldType sends rawkeydown and rawkeyup, so cannot be trapped by keydown/keyup.
wipe out the backslash character.
-
- VIP Livecode Opensource Backer
- Posts: 365
- Joined: Mon Jun 10, 2013 1:32 pm
Re: sending a Backspace to a on Keyup commnd
Hi All,
I decided to refactor some old code that has been working for a few years and used the select and insert method on the focused object.
I thought rawkeyup or keyup would make it easier so started with that and kept getting a cant find handler error.
I did a search and found this thread using ALMOST the same method except the whole send was inside a single string except mine was
originally
I copied Craig's method exactly as well and gave it its own key but still no joy.
I tested different ways including going back to version 6 - Now after 3+ hours over 2 days I give up I give Up.
I must be missing something simple - can't see the forest for the trees.
The real code is a virtual keyboard that works perfectly except occasionally when delete and a cursor is used (no big problem) but it is something that always bugged me.
Can someone please take a look at the attached (version 6 LC) stack and see where I am going wrong
Thanks so much
*** EDIT
I came back into it today and the 4 buttons with a behavior weren't firing.
Turns out just before I uploaded I decided to rename the stack from untitled to upkey - LC did not update the behavior name
so i have reuploaded - still doesn't work
Lagi
I decided to refactor some old code that has been working for a few years and used the select and insert method on the focused object.
I thought rawkeyup or keyup would make it easier so started with that and kept getting a cant find handler error.
I did a search and found this thread using ALMOST the same method except the whole send was inside a single string except mine was
originally
Code: Select all
Send "Keyup" && lcKey
I copied Craig's method exactly as well and gave it its own key but still no joy.
I tested different ways including going back to version 6 - Now after 3+ hours over 2 days I give up I give Up.
I must be missing something simple - can't see the forest for the trees.
The real code is a virtual keyboard that works perfectly except occasionally when delete and a cursor is used (no big problem) but it is something that always bugged me.
Can someone please take a look at the attached (version 6 LC) stack and see where I am going wrong
Thanks so much
*** EDIT
I came back into it today and the 4 buttons with a behavior weren't firing.
Turns out just before I uploaded I decided to rename the stack from untitled to upkey - LC did not update the behavior name
so i have reuploaded - still doesn't work
Lagi
- Attachments
-
- KeyUp2.zip
- (1.03 KiB) Downloaded 166 times
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: sending a Backspace to a on Keyup commnd
Lagi.
Two things. One, you need something like this, not what you had:
That was the easy part. I reWrote your button script, and it did not work. I made a new field, changed the destination, and it did. Not sure what is "special" about your field "F1". Maybe fool around and find out, or delete it and make a new one.
Craig
Two things. One, you need something like this, not what you had:
Code: Select all
on mouseUp
send "keyup" && random(9) to me
end mouseUp
on keyUp tkey
put tKey into fld "f1"
end keyUp
Craig
-
- VIP Livecode Opensource Backer
- Posts: 365
- Joined: Mon Jun 10, 2013 1:32 pm
Re: sending a Backspace to a on Keyup commnd
Hi Thanks Craig,
I was playing around so much I changed your code to "hard" code put it inside the quotes as you did then put it outside
I was going loopy i will delete all the buttons and make 1 only without a behavior and carry on from there.
In fact looking at that it wont do what i want it to do. I was going to het this working and then use rawkeyup.
The ide is that i will let LC control the backspace delete and insertion by simulating the keypress in the field.
The way I have got it working at the moment I append after and trap the arrow and delete keys and insert - but I think its messy especially when they delete backwards at the beginning of a line. This is why i decided to see if i can inset using the inbuild keyup/rawkeyup handlers of the field.
Thanks for your help
I was playing around so much I changed your code to "hard" code put it inside the quotes as you did then put it outside
I was going loopy i will delete all the buttons and make 1 only without a behavior and carry on from there.
In fact looking at that it wont do what i want it to do. I was going to het this working and then use rawkeyup.
The ide is that i will let LC control the backspace delete and insertion by simulating the keypress in the field.
The way I have got it working at the moment I append after and trap the arrow and delete keys and insert - but I think its messy especially when they delete backwards at the beginning of a line. This is why i decided to see if i can inset using the inbuild keyup/rawkeyup handlers of the field.
Thanks for your help