Delete Character In Field.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Delete Character In Field.
Hi Guys, I have a quick question.
Let's say I have a field with the contents "Tester". If I was to generate the message "backspaceKey", how would I delete the "s" when the cursor is behind the "s"? Is there a way I can see the char number that the cursor is at so that I can delete the character that precedes the cursor?
I hope I explained myself clearly!!!
Many Thanks,
Googie.
Let's say I have a field with the contents "Tester". If I was to generate the message "backspaceKey", how would I delete the "s" when the cursor is behind the "s"? Is there a way I can see the char number that the cursor is at so that I can delete the character that precedes the cursor?
I hope I explained myself clearly!!!
Many Thanks,
Googie.
Re: Delete Character In Field.
Hi.
On a new card with a field 1 containing your text and a button, put this in the button script:
If the cursor is blinking just behind an "s" you will get a dialog. I assume you can expand on this with your deletion thing.
Craig
On a new card with a field 1 containing your text and a button, put this in the button script:
Code: Select all
on mouseUp
if char (word 2 of the selectedChunk) of fld 1 = "s" then answer "You have an S!"
end mouseUp
Craig
Re: Delete Character In Field.
I had an extra minute.
Craig
Code: Select all
on mouseUp
get word 2 of the selectedChunk
if char it of fld 1 = "s" then delete char it of fld 1
end mouseUp
Re: Delete Character In Field.
Googie.
Just a question. Does "Googie" possibly derive from an old Theodore Sturgeon science fiction story?
Craig
Just a question. Does "Googie" possibly derive from an old Theodore Sturgeon science fiction story?
Craig
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Delete Character In Field.
This is slightly off-topic, but what is the logic behind 'word 2'?
If I do this:
I get 'char'
and if I do this:
I get a number (the number of the letter just before the cursor in the field), and if
I do this:
I will always get 'to'.
If I do this:
Code: Select all
on mouseUp
put word 1 of the selectedChunk
end mouseUp
and if I do this:
Code: Select all
on mouseUp
put word 2 of the selectedChunk
end mouseUp
I do this:
Code: Select all
on mouseUp
put word 3 of the selectedChunk
end mouseUp
Re: Delete Character In Field.
Richmond.
I do not understand your question. Make a quick stack as I described but in the button script only retrieve the selectedChunk itself. Place the cursor somewhere in the text of the field and click the button .
See?
Craig
I do not understand your question. Make a quick stack as I described but in the button script only retrieve the selectedChunk itself. Place the cursor somewhere in the text of the field and click the button .
See?
Craig
Re: Delete Character In Field.
OH BOY, Richmond...
Will surely enlighten you, if not, get another hobby. 
Code: Select all
put the selectedchunk

-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Delete Character In Field.
With the cursor between 2 letters (i.e. NO text is selected) I get nothing.
That still does not explain word 1, word 2, or word 3.
A single character before the cursor insertion point is not a word.
That still does not explain word 1, word 2, or word 3.
A single character before the cursor insertion point is not a word.
Last edited by richmond62 on Mon Dec 09, 2024 6:54 pm, edited 1 time in total.
Re: Delete Character In Field.
Some hints...
Button script:
No text selected, cursor is blinking after the 2nd character in the field:
Some text selected:
Button script:
Code: Select all
put the selectedchunk
Re: Delete Character In Field.
Richmond.
Anyway, it is not really true that "no text is selected", as you put it, though I understand your point. When the selectedChunk returns a value that has word 2 greater than word 4, it indicates just that case, a blinking cursor in the body of the text but with no actual character(s) selected.
One might say that the existence of the cursor within the text constitutes a selection, albeit a very narrow one.
Anyway, a blinking cursor is rightly considered to be a participant in the text, and the selectedChunk locates it with two "reverse" numbers, the chars after and before the cursor.
Craig
I bet you do, if you really have a blinking cursor.With the cursor between 2 letters (i.e. NO text is selected) I get nothing.
Anyway, it is not really true that "no text is selected", as you put it, though I understand your point. When the selectedChunk returns a value that has word 2 greater than word 4, it indicates just that case, a blinking cursor in the body of the text but with no actual character(s) selected.
One might say that the existence of the cursor within the text constitutes a selection, albeit a very narrow one.

Anyway, a blinking cursor is rightly considered to be a participant in the text, and the selectedChunk locates it with two "reverse" numbers, the chars after and before the cursor.
Craig
Last edited by dunbarx on Tue Dec 10, 2024 9:45 pm, edited 1 time in total.
Re: Delete Character In Field.
Richmond: we evaluate the string returned in the selectedChunk. The first four words of that string include the character positions. I'm not sure what you were expecting?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com