Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / EditBox: find the point at which a change was made

Author
Message
Jambo B
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 26th Jul 2015 14:54
Hi all,

I'm doing a lot of messing around with strings, and I'm trying to find the point in a string at which a change was made by the user.

What I really need is a command like GetEditBoxCursorPosition() - can't believe that's not there!

I've tried comparing the string from the edit box and the string stored in a variable, to locate the character index at which they become different, but this doesn't work if the strings contain more than one occurrence of the same letter together.

e.g.

Old string: abcdddddddefgh
New string: abcddddddddefgh

Impossible to tell where the extra 'd' was added!

Can anyone think of a solution?

Thanks,

James
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Jul 2015 15:40
You really need that missing command!

How about this...

I was trying to think of a way to encode a second copy to compare against, but I don't think it is possible.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Jul 2015 15:54
hmm, i think u need to handle the input self and display it like a editbox.

AGK 108 (B)19 + AppGameKit (Steam) V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Jambo B
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 27th Jul 2015 12:40
Thanks BatVink and Markus. I've been racking my brains to think of a way to do it, and the only thing I've come up with is Markus' suggestion of writing my own edit box.

That's problematic in itself - if I want to release my app on iOS and Android, my edit box would have to behave itself on those OSes as well. I could spend weeks on that!

Paul (if you're reading this!) please would you add that missing command?! I'm a bit stuck without it!

James
Rickynzx
12
Years of Service
User Offline
Joined: 19th Dec 2011
Location: Troon, Scotland
Posted: 27th Jul 2015 13:09 Edited at: 27th Jul 2015 13:11
it is possible to track the key input.
track the length of the word then every time the left or right key is pressed you can have a variable telling you the position of the cursor...(I think)
eg if you type a 5 letter word, then press the left key once, you will know that the cursor is at position 4 by taking the word length and subtracting the amount of times the left key has been pressed.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Jul 2015 13:49
The problem is that you can change the cursor position with touch/mouse. At that point you can't retrieve the position.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Jul 2015 13:53
one idea i have is to overwrite the position with your value each sync
but i don't know if this works well.
SetEditBoxCursorPosition ( index, pos )

@Rickynzx
do not forget you can move the cursor with mouse hit or touch.

AGK 108 (B)19 + AppGameKit (Steam) V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-11-25 19:44:56
Your offset time is: 2024-11-25 19:44:56