TEdit / NumbersOnly lazarus / 21-General ---------------------------------------------------------------------- BubikolRamios · 2024-04-07 03:03 One can easily change value to < 0 i.e. -1 etc with code under control to the right of TEdit or by pasting negative value into TEdit. But can not type '-' into TEdit --> Unacceptable character ...  Debatable or bug ? BTW: '1.7' would also be a number or not ? Does not let decimal numbers in. IsNumber recognizes decimal numbers as number. ---------------------------------------------------------------------- dsiders · 2024-04-07 03:41 Quote from: BubikolRamios on April 07, 2024, 05:03:08 amOne can easily change value to < 0 i.e. -1 etc with code under control to the right of TEdit or by pasting negative value into TEdit. But can not type '-' into TEdit --> Unacceptable character ...  Debatable or bug ? BTW: '1.7' would also be a number or not ? Does not let decimal numbers in. IsNumber recognizes decimal numbers as number. Well, it's documented. Does that count? https://lazarus- ccr.sourceforge.io/docs/lcl/stdctrls/tcustomedit.numbersonly.html ---------------------------------------------------------------------- Bart · 2024-04-07 20:26 It's the way M$ implemented it: in a dumb-ass way. Bart ---------------------------------------------------------------------- Curt Carpenter · 2024-04-07 21:24 Surely at this late date someone has created an edit control that accepts a floating point number?   I guess I just never got around to looking for such a thing. ---------------------------------------------------------------------- jamie · 2024-04-07 21:32 Quote from: Curt Carpenter on April 07, 2024, 11:24:27 pmSurely at this late date someone has created an edit control that accepts a floating point number?   I guess I just never got around to looking for such a thing. Of there are.. TMaskEdit TFoatSpinEdit and ofcourse,  your own custom one monitoring the Keyboard and rejecting or replacing values. ---------------------------------------------------------------------- paule32 · 2024-04-07 21:36 a option can be, to sub class the TEdit class, and check the keypress's with onKeyPress, onKeyDown, onKeyUp. you have different signature parameters of these event members, so you could catch virtual key code like (e.g. VK_F1) or check if you have the char code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if ((key >= '0') and (key <= '9')) then begin  // do thisend elseif key = #13 then begin  // do other thingsend else ... at end, if you don't would like a beep, you can add the line: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i key := #0; which clears the keyboard input buffer. hope this helps ---------------------------------------------------------------------- Bart · 2024-04-08 06:25 Quote from: jamie on April 07, 2024, 11:32:48 pmOf there are.. TMaskEdit TFoatSpinEdit And TFloatSpinEditEx Bart ---------------------------------------------------------------------- Ally · 2024-04-08 06:50 Hello, my component DecimalNumberEdit is a component for entering numbers. The component is available in the "Online Package Manager" under "RhsPack". The input field only accepts valid numbers that can be limited using the Matrix property. The component provides four new properties. 1. Matrix (string)    The number format is defined via this property.    Examples:    99.99 Allows you to enter values in the range from 0 to 99.99 with two decimal places.    -50.9 Allows you to enter values in the range from -50.9 to 50.9 with one decimal place.    250.000 Allows you to enter values in the range from 0 to 250 with three decimal places.    -500 Allows you to enter values in the range from -500 to 500 without decimal places. 2. Value (Extended)    Returns the extended value of the entered value.    This value can be evaluated during input and represents the value currently entered in the input field. 3. EnterKey (Boolean)    Allows the Enter key to be used in the same way as the Tab key. 4. WarningTone (Boolean)    Outputs a warning tone when illegal entries are made. Under Windows the localization settings such as the DecimalSeparator is automatically adopted. Should the project also use the localization settings under Linux / Unix, you should add the entry clocale to the project uses. Example: uses   {$IFDEF UNIX}{$IFNDEF DARWIN}    clocale, // Sets the localization settings (number, date and time formats)   {$ENDIF}{$ENDIF}   SysUtils, Forms, ...... greetings Roland