Enable "overwrite" in text field

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

Post Reply
ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Enable "overwrite" in text field

Post by ale870 » Mon Aug 10, 2009 12:26 am

Hello,

how can I enable "overwrite" in a text field?

Thank you!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Aug 10, 2009 9:19 pm

Dear ale870,

What do you mean exactly?

It is always possible to use the put command to put data into a field.

You can set the lockText to false to type in a field directly. You can do this in the property inspector or by script.

Please, make sure to read the users manual, which is included with Revolution as a pdf file.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

Post by massung » Mon Aug 10, 2009 9:53 pm

I think he means toggling INSERT vs. OVERWRITE as in the user pressed the "insert" key and now everything they type overwrites characters instead of inserting them.

Jeff M.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Aug 10, 2009 10:20 pm

Hi,

If you want to handle the insert key (which my keyboard currenty doesn't have), your field might need a rawKeyDown handler:

on rawKeyDown thekey
put theKey
end rawKeyDown

Suppose that this puts 12345 into the message box, then you need to write the following script replacing the one above:

Code: Select all

on rawKeyDown thekey
  if theKey is 12345 then
    if the hilite of btn "Toggle" then
      delete the selection
    else
      select before the selectedChunk
    end if
  end if
  pass rawKeyDown
end rawKeyDown
This might do what you want. Let me know how it goes.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Tue Aug 11, 2009 12:31 am

Thank you.
Yes I want to manage "insert" and "overwrite". But I want to manage those properties not using the keyboard (neither my keyboard has that button!), but via code. Something like:

Code: Select all

set the overwrite of field "x" to true
(not real code, just an example!)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Aug 11, 2009 12:48 am

Dear ale870,

Jeff and I have made a few guesses about what exactly you want, but apparently we're not entirely correct. Can you give an exact description of what you want to happen?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Tue Aug 11, 2009 9:43 am

I'm sorry, I'm sure I was not clear (furthermore my english is not "perfect").

Basically I want to enable "INSERT/OVERWRITE" features (as @massung said), but not using key on the keyboard.

Well, when you open a text editor, you start to write something, and if you press OVERWRITE key on the keyboard, typed letters overwrite existing ones. See this example:

Code: Select all

this is my text
If I put my cursor between the words "this is", when I start to type on the keyboard in overwrite mode, the remaining text ("is my text") will be over-written by the new text I'm typying:

Code: Select all

this is my text
     ^
PUT CURSOR HERE:

THEN I START TYPING (I will write "elephant")...

this elephantxt
As you can see, text "elephant" has overwritten old text.

I want to enable this features (enable INSERT or OVERWRITE) not using the right key on the keyboard but using a function in RunRev (some property like "the overwrite of field..."). Obviously, this property does not exist (I think), so I "invented" it just to make an example.



[/code]

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

Post by Klaus » Tue Aug 11, 2009 10:17 am

Hi ale870,

there is nothing built in that would do this, so you will have to script this (always extremely strange to me :)) feature by yourself.


Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Aug 11, 2009 10:45 am

Hi ale870,

Put the following into the script of a field.

Code: Select all

on keyDown
   if length(the selectedText) is 0 then
      delete char (word 2 of the selectedChunk) of me
   else
      delete the selectedChunk
   end if
   pass keyDown
end keyDown
This should get you started.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Tue Aug 11, 2009 10:47 am

Thank you! THat is a good starting point!

Post Reply