Tedit selected text lazarus / 21-General ---------------------------------------------------------------------- Paolo · 2023-09-18 19:41 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. ---------------------------------------------------------------------- Bart · 2023-09-18 20:06 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. Bart ---------------------------------------------------------------------- Paolo · 2023-09-24 20:11 The criteria how text Is select Is coming from OS settings ? or .. ? ---------------------------------------------------------------------- Bart · 2023-09-25 10:01 You can override the DoubleClick method to make the component do whatever you want. Bart ---------------------------------------------------------------------- TRon · 2023-09-25 10:10 Quote from: Paolo on September 24, 2023, 10:11:15 pmThe criteria how text Is select Is coming from OS settings ? or .. ? For fun I tried to select the quoted -100 in your first post e.g. " ie the whole '-100'. " by double clicking the number 100. Now try to guess what happened ---------------------------------------------------------------------- Paolo · 2023-09-25 11:20 In my replay n.4 it was my curiosity to know "who" defined the selection criteria of text in tedit. For example if you have as text '100-100' (quotes are not really there), a doubleclick on one of '100' it becames the selected text, if you have '100+100' a doubleclick on one '100' selects the whole string. Did you see a different behaviour? ---------------------------------------------------------------------- TRon · 2023-09-25 11:27 Quote from: Paolo on September 25, 2023, 01:20:10 pmIn my replay n.4 it was my curiosity to know "who" defined the selection criteria of text in tedit. Yeah, I understood what you meant. Making it more clear for you then: OS (but individual software might influence default behaviour). QuoteFor example if you have as text '100-100' (quotes are not really there), a doubleclick on one of '100' it becames the selected text, if you have '100+100' a doubleclick on one '100' selects the whole string. Did you see a different behaviour? That is indeed remarkable because for me it selects the number 100 only. Either the first one or the last one depending on what number 100 I double-clicked. ---------------------------------------------------------------------- Paolo · 2023-09-25 15:01 @TRon, are you on windows ? ---------------------------------------------------------------------- TRon · 2023-09-25 16:00 @Paolo: Debian Linux, Mate with Marco and tested with FireFox 117.0.1 ---------------------------------------------------------------------- Bart · 2023-09-25 19:46 Quote from: Paolo on September 25, 2023, 01:20:10 pmFor example if you have as text '100-100' (quotes are not really there), a doubleclick on one of '100' it becames the selected text, if you have '100+100' a doubleclick on one '100' selects the whole string. Did you see a different behaviour? Yeah, confirmed on Win10. And Delphi 7 behaves the same. Apparently it's the OS that does it (at least in DblClick (implemented in TControl) we do nothig ourselves). It shows this behaviour for '1+1+1', but not for 'test+test', but it does for '1+a', but for '1+a+b' it selects '1+a' if you double click anywhere in the '1+a' part, otherwise it selects the '+b' part. There will of course be some reasoning behind this behaviour, but it's beyond me. Bart ---------------------------------------------------------------------- Paolo · 2023-09-25 20:02 Thanks Bart for checking. Since I have a lot of numerical input it is annoying that to overwrite a data in case of negative value the user has to edit manually the '-' sign. However if, as in my case, I have a lot of edit, moving among them via "TAB" always select the whole text (this makes sense because edit doesn't know what you want select). Ciao. PS: if I discover where is such setting I'll post here. ---------------------------------------------------------------------- Paolo · 2023-09-25 21:03 it seems no published settings in windows are available to tune this behaviour  https://superuser.com/questions/203163/where-do-i-configure-the- default-text-selection-behavior-in-windows at the end "SelectAll" is fine for me... thaks to all.