Author Topic: Tedit selected text  (Read 246 times)


  • Sr. Member
  • ****
  • Posts: 420
Tedit selected text
« on: September 18, 2023, 09:41:06 pm »
Hello (FPC/LAZ=3.2.2/2.2.6)

I have a class derived from Tedit where the main purpose is to handle numerical input.

I noticed that if you put on a form a TEdit, say Edit1, and as text you put '100', a double clicking on the number select the whole number, in this way it can be easy overwritten, but if the number (actually the text) is '-100' a double click omits the '-' in the slected text, how can implement a doubleclick that select "negative numbers", ie the whole '-100'. (In this case a sort of "selectall" should be sufficent anyway).

thank you.
« Last Edit: September 18, 2023, 09:45:23 pm by Paolo »


  • Hero Member
  • *****
  • Posts: 5063
    • Bart en Mariska's Webstek
Re: Tedit selected text
« Reply #1 on: September 18, 2023, 10:06:46 pm »
That depends wether or not the '-100' is in fact the complete text or just a part of the text.
In the first case, just do a SelectAll.
In the seceond case, determine the value of SelStart, see if the character before the selection is a '-', and if that is the case decrement SelStart by 1.



TinyPortal © 2005-2018