View previous topic :: View next topic |
Author |
Message |
badmadevil
Joined: 17 Feb 2008 Posts: 2
|
Posted: Sat May 10, 2008 1:42 am Post subject: Help request for custom text highlight at TextBox |
|
|
Hi,
I'm a newbie in programming, especially gui-coding.
I'm implementing a GUI based SNUSP interpreter using DFL, similar to this javascript web version:
http://www.quirkster.com/snusp/snusp-js.html
The problem is to, on a textbox, highlight the char the current source code pointers pointed at (eg. x-th char, y-th line, zero-base).
The methods I can think of (may be naive):
A) use drawText & drawTextDisabled ;
B) make the text background color transparent (or do nothing during textbox's onPaintBackground ?), then draw a filled box on window behind the textbox.
The text font will be fixed-size monospaced.
A sub-problem is to locate the target char position.
Some example code is much appreciated, thank you. |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Mon May 19, 2008 8:12 pm Post subject: Re: Help request for custom text highlight at TextBox |
|
|
If you use a RichTextBox you can change the background color of different ranges of text. The newer snapshots contain extra methods to work with the positions of the characters, for example getCharIndexFromPosition from the base class TextBoxBase. |
|
Back to top |
|
|
badmadevil
Joined: 17 Feb 2008 Posts: 2
|
Posted: Mon Jun 02, 2008 3:51 pm Post subject: Re: Help request for custom text highlight at TextBox |
|
|
Thank for reply and sorry for my late response.
I've solved the problem by using Label as cursor. By measureText(), I can get the exact position of the Label cursors on their parent Textbox control (fixed-size font). In each time frame, each cursors' location, color, visibility and text is updated accordingly. It seems work fine.
Thanks again. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|