PDA

View Full Version : Modified TEdit?



Darkhog
17-08-2014, 08:00 PM
Can anyone make version of TEdit that can show any text character as "text cursor"/caret/whatever it's called instead of standard bar (|)?

SilverWarior
17-08-2014, 09:27 PM
I haven't tried anything like this but not long ago I have seen someone requesting similar thing on Stack Owerflow.
You can check the SO thread here: http://stackoverflow.com/questions/25227599/how-to-implement-a-special-indicator-in-a-single-or-multi-line-edit-control
I hope this will help.

Darkhog
18-08-2014, 03:52 PM
OK. I've got it to work a bit and I've got somewhat nice, dos-like underscore, but now curious thing happen: When I move mouse outside edit, caret moves back to top (had to move it bit downwards) and turns into um... overscore (is that even a word). Here's my code:


procedure TStoryProcessor.cmdMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var point:TPoint;
begin
//set caret
CreateCaret(cmd.Handle,0,16,2);
GetCaretPos(point);
SetCaretPos(point.x,point.y+20);
ShowCaret(cmd.Handle);

end;

I've even tried to put it into OnMouseLeave of edit, but to no result.

SilverWarior
19-08-2014, 06:13 AM
I found a page with code example of how to change the default caret for TEdit. I haven't tested it out so I'm not sure it works. But go and check it out.
http://www.delphitips.net/2009/02/17/own-cool-text-cursor-in-editbox/

pitfiend
21-08-2014, 01:48 AM
why not a combobox? that way you could do something like zork with history of previous commands

Darkhog
21-08-2014, 06:39 AM
Pitfiend, because I don't want to make it easy for the player.

Cybermonkey
21-08-2014, 06:20 PM
Should it be retro like? Then why not use pure Freepascal with ptcgraph?
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1318&stc=1

Darkhog
21-08-2014, 07:14 PM
Well, it is supposed to be semi-retro. I want to revive a genre, not move backwards.