How to Pass key in livecode
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to Pass key in livecode
Hi gurus,
How to pass a key from button?.
i have a number of keys to pass inside button. if i click the button. it will pass value (eg:e) into the field where the cursor is.
Please find the attached zip.
Thanks
Samjith
How to pass a key from button?.
i have a number of keys to pass inside button. if i click the button. it will pass value (eg:e) into the field where the cursor is.
Please find the attached zip.
Thanks
Samjith
- Attachments
-
- help.zip
- (768 Bytes) Downloaded 239 times
Re: How to Pass key in livecode
Hi Samjith,
I hope I understood what you are trying to do.
put this code into your button
please look up in the dictionary
selectedChunk
numToChar
Kind regards
Bernd
I hope I understood what you are trying to do.
put this code into your button
Code: Select all
on mouseUp
--pass "101"--to show "e" in field "Field"
put the selectedChunk of field "field" into tChunk -- find out if field "field" has focus
if tChunk is "" then -- field has not focus
answer "field is not selected"
exit mouseUp
end if
-- convert number to char
put "101" into aKey
put numToChar(aKey) into tChar
-- find out if the cursor is blinking or a selection has been made in field "field"
if word 2 of tChunk > word 4 of tChunk then
put tChar after char (word 4 of tChunk) of field "field"
else
-- handle a selection of one or more chars in field
put tChar into char (word 2 of tChunk) to (word 4 of tChunk) of field "field"
end if
end mouseUp
selectedChunk
numToChar
Kind regards
Bernd
Re: How to Pass key in livecode
yes, works fine. iam trying this with a large code. thanks
how to pass leftarrow,rightarrow,uparrow,downarrow by button
how to pass leftarrow,rightarrow,uparrow,downarrow by button
Re: How to Pass key in livecode
Hi samjith,
It is easier to understand when you give a use case. That means what you want to accomplish with arrow keys? Do you want to move the position of the cursor?
Kind regards
Bernd
I don't understand, what is leftarrow etc supposed to do.how to pass leftarrow,rightarrow,uparrow,downarrow by button
It is easier to understand when you give a use case. That means what you want to accomplish with arrow keys? Do you want to move the position of the cursor?
Kind regards
Bernd
Re: How to Pass key in livecode
Bernd.
i think he wants to trap the "arrowKey" message.
@Samjith. Is this true? Please look this up in the dictionary, and experiment for a little while.
Craig Newman
i think he wants to trap the "arrowKey" message.
@Samjith. Is this true? Please look this up in the dictionary, and experiment for a little while.
Craig Newman
Re: How to Pass key in livecode
Hi,
Actually i want to move the position of the cursor when i click a button
Please find the zip, so you can unuderstand what i meant.
I think the pass command in this stack not working or cursor focus not in the field. very much confused
i need to do deletekey,backspace etc to do like this
Samjith
Actually i want to move the position of the cursor when i click a button
Please find the zip, so you can unuderstand what i meant.
I think the pass command in this stack not working or cursor focus not in the field. very much confused
i need to do deletekey,backspace etc to do like this
Samjith
- Attachments
-
- help.zip
- (1.47 KiB) Downloaded 215 times
Re: How to Pass key in livecode
Hi Samjith,
I still don't understand what you are trying to do but from looking at your stack you try to move the arrowKeys and delete in a field.
The way you did it does not work (or at least I can't get it to work) that you send the arrowKey left message to the field. Apparently the "true" arrowKey left is only received by the field itself when the user types it.
To simulate a arrowkey left and right and backspace and forward delete I made a stack that has 4 buttons that simulate that action by using the selectedChunk.
Is that what you are looking for?
It would help a lot if you could describe what you want to do.
as an example
I want to use a button to move the cursor in a field and another button to delete selections or characters in the field where the cursor is or the whole selection. I am trying to simulate a keyboard with buttons because my users can only click on buttons and can not use a keyboard.
Or something like that as a use case
I know that selectedChunk is complicated but I don't see a way around this for what I guess you are trying to do.
Kind regards
Bend
I still don't understand what you are trying to do but from looking at your stack you try to move the arrowKeys and delete in a field.
The way you did it does not work (or at least I can't get it to work) that you send the arrowKey left message to the field. Apparently the "true" arrowKey left is only received by the field itself when the user types it.
To simulate a arrowkey left and right and backspace and forward delete I made a stack that has 4 buttons that simulate that action by using the selectedChunk.
Is that what you are looking for?
It would help a lot if you could describe what you want to do.
as an example
I want to use a button to move the cursor in a field and another button to delete selections or characters in the field where the cursor is or the whole selection. I am trying to simulate a keyboard with buttons because my users can only click on buttons and can not use a keyboard.
Or something like that as a use case
I know that selectedChunk is complicated but I don't see a way around this for what I guess you are trying to do.
Kind regards
Bend
- Attachments
-
- controlField.livecode.zip
- use buttons to move cursor right or left and delete text
- (1.38 KiB) Downloaded 234 times
Re: How to Pass key in livecode
Hi Bend,
My wish is to do macro.
store all events in the field (backspace,delete, keys, etc). and wrote it in a button
When i want to load the macro (click button), it will works,
Please find the attached stack. In this stack selectedChunk not work in linux but works in mac.
Thanks
Samjith
My wish is to do macro.
store all events in the field (backspace,delete, keys, etc). and wrote it in a button
When i want to load the macro (click button), it will works,
Please find the attached stack. In this stack selectedChunk not work in linux but works in mac.
Thanks
Samjith
- Attachments
-
- Sam.zip
- (1.05 KiB) Downloaded 242 times
Re: How to Pass key in livecode
Hi Samjith,
To be sure that the button does not take away the focus from the field try in the properties inspector the unselect "traversalOn" or focusable for the button
did the field have focus on Linux? That means the cursor is blinking?
Try it agan on Linux and click into the field before you click the button.
If everything fails try to select the field in the button of you script.
If you want a macro of what was typed into the field I made a stack that records the changes in a "recording" field (the upper one) and that stores it in a custom property of the "recording" field as an array. You can then replay the typing including deletions and including the cursor position by pushing button "replayRecording"
maybe something like this is all you are looking for. If you want to go that way you would have to make yourself familiar with the techniques used here.
Especially arrays and custom properties, as well as script local variables.
Kind regards
Bernd
I don't have a Linux installation but I know that some operating systems the focus of the field can be taken away by buttons.In this stack selectedChunk not work in linux but works in mac
To be sure that the button does not take away the focus from the field try in the properties inspector the unselect "traversalOn" or focusable for the button
did the field have focus on Linux? That means the cursor is blinking?
Try it agan on Linux and click into the field before you click the button.
If everything fails try to select the field in the button of you script.
If you want a macro of what was typed into the field I made a stack that records the changes in a "recording" field (the upper one) and that stores it in a custom property of the "recording" field as an array. You can then replay the typing including deletions and including the cursor position by pushing button "replayRecording"
maybe something like this is all you are looking for. If you want to go that way you would have to make yourself familiar with the techniques used here.
Especially arrays and custom properties, as well as script local variables.
Kind regards
Bernd
- Attachments
-
- recordTyping.livecode.zip
- (2.32 KiB) Downloaded 245 times
Re: How to Pass key in livecode
Hi Bernd,
Thanks for the magical works
. I wondered, how it works.
I need exactly like the same work. means field 1 is not empty while starts recording,
Thanks
Samjith
Thanks for the magical works

I need exactly like the same work. means field 1 is not empty while starts recording,
Thanks
Samjith