Page 1 of 1

Enable "overwrite" in text field

Posted: Mon Aug 10, 2009 12:26 am
by ale870
Hello,

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

Thank you!

Posted: Mon Aug 10, 2009 9:19 pm
by Mark
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

Posted: Mon Aug 10, 2009 9:53 pm
by massung
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.

Posted: Mon Aug 10, 2009 10:20 pm
by Mark
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

Posted: Tue Aug 11, 2009 12:31 am
by ale870
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!)

Posted: Tue Aug 11, 2009 12:48 am
by Mark
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

Posted: Tue Aug 11, 2009 9:43 am
by ale870
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]

Posted: Tue Aug 11, 2009 10:17 am
by Klaus
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

Posted: Tue Aug 11, 2009 10:45 am
by Mark
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

Posted: Tue Aug 11, 2009 10:47 am
by ale870
Thank you! THat is a good starting point!