sending a Backspace to a on Keyup commnd

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 233
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Tue Oct 01, 2019 4:27 am

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.
Clarence Martin
chipsm@themartinz.com

[-hh]
VIP Livecode Opensource Backer
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

Post by [-hh] » Tue Oct 01, 2019 8:14 am

Just to make things as simple as possible:

Code: Select all

on mouseUp
  select char 5 of fld 1 -- or whatever char
  type numToChar(8)
end mouseUp
Works with LC 6/7/8/9.

Type sends rawkeydown and rawkeyup, so cannot be trapped by keydown/keyup.
shiftLock happens

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

Re: sending a Backspace to a on Keyup commnd

Post by bogs » Tue Oct 01, 2019 10:12 am

That is pretty simple and slick, nice one -hh.
Image

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 233
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Tue Oct 01, 2019 11:56 am

HH,
your script works also!
Clarence Martin
chipsm@themartinz.com

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 233
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Tue Oct 01, 2019 12:03 pm

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.
Attachments
stateDropDownList.zip
(3.17 KiB) Downloaded 55 times
Clarence Martin
chipsm@themartinz.com

[-hh]
VIP Livecode Opensource Backer
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

Post by [-hh] » Tue Oct 01, 2019 4:15 pm

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).

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

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 233
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Tue Oct 01, 2019 4:35 pm

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.
Clarence Martin
chipsm@themartinz.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5071
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: sending a Backspace to a on Keyup commnd

Post by richmond62 » Tue Oct 01, 2019 4:52 pm

Type sends rawkeydown and rawkeyup, so cannot be trapped by keydown/keyup.
That's why, in my code above, I had to have 2 type signals so the first one would
wipe out the backslash character. 8)

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”