Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Soll die Taste auf dem Nummernblock ein Dezimaltrennzeichen sein? (https://www.delphipraxis.net/186496-soll-die-taste-auf-dem-nummernblock-ein-dezimaltrennzeichen-sein.html)

Der schöne Günther 14. Sep 2015 08:35

AW: Soll die Taste auf dem Nummernblock ein Dezimaltrennzeichen sein?
 
Ich bin bislang nicht dazu gekommen und habe es so gelassen, wie es momentan ist:
  1. Das VCL-Touchkeyboard zeigt an, was auch auf der physischen Tastatur ist
  2. Es wird auch eingegeben, was auf den Tasten steht. Ein Franzose gibt also einen Punkt ein.
  3. Das Programm prüft einfach auf alle bekannten Trennzeichen. Wenn bei einem ein vernünftiger Wert rauskommt dann ist das Programm zufrieden

Also so:
Delphi-Quellcode:
function TFloatInputPopup.tryParse(out value: Single): Boolean;
const
   knownSeparators: TArray<Char> = ['&#1643;', ',', '.']; // 1st = Momayyez
var
   testedSeparator:   Char;
   formatSettings:      TFormatSettings;
begin
   Result := False;

   formatSettings := TFormatSettings.Create(LOCALE_INVARIANT);
   for testedSeparator in knownSeparators do begin
      formatSettings.DecimalSeparator := testedSeparator;
      Result := Result or Single.TryParse(inputEdit.Text, value, formatSettings);
      if Result then Break;
   end;
end;
Und ja, im Endeffekt ist das die billigste Methode. Und beinhaltet noch gar nicht die Arbeit welche du dir mit dem TouchKeyboard gemacht hast :oops:


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:24 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz