Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » Input mask on an EditInt
Input mask on an EditInt [message #53076] Fri, 21 February 2020 16:42 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I have the need to apply an input mask on an EditInt. The user will enter a 6 digits integer number, but it has to be shown with a point after the first 2 digits. e.g. "201234" will be shown as "20.1234". Internally the input is treated as an integer.

Is there a quick way to implement that kind of an in input mask?

Thanks,
gio
Re: Input mask on an EditInt [message #53081 is a reply to message #53076] Sun, 23 February 2020 23:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Giorgio wrote on Fri, 21 February 2020 16:42
Hi there,
I have the need to apply an input mask on an EditInt. The user will enter a 6 digits integer number, but it has to be shown with a point after the first 2 digits. e.g. "201234" will be shown as "20.1234". Internally the input is treated as an integer.

Is there a quick way to implement that kind of an in input mask?

Thanks,
gio


You need to provide your Convert. Handle text<->int conversion in your custome Format/Scan.

Mirek
Re: Input mask on an EditInt [message #53083 is a reply to message #53081] Mon, 24 February 2020 12:13 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi,
is there an example of that?

At the moment I have changed the field from EditInt to EditString, create the converter (see below) and "bound" the converter to the EditString, but this crashes the application.

Thanks,
gio

ConvertOrderNumber c;
order_number.SetConvert(c); //<-- order_number is the EditString in the .lay file


struct ConvertOrderNumber : Convert{
  Value Format(const Value &q) const
  {
    String input=AsString(q);
    return input.Left(2)+"."+input.Right(input.GetCount()-1);
  }
};
Re: Input mask on an EditInt [message #53087 is a reply to message #53083] Mon, 24 February 2020 16:18 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Giorgio wrote on Mon, 24 February 2020 12:13
Hi,
is there an example of that?

At the moment I have changed the field from EditInt to EditString, create the converter (see below) and "bound" the converter to the EditString, but this crashes the application.

Thanks,
gio

ConvertOrderNumber c;
order_number.SetConvert(c); //<-- order_number is the EditString in the .lay file


struct ConvertOrderNumber : Convert{
  Value Format(const Value &q) const
  {
    String input=AsString(q);
    return input.Left(2)+"."+input.Right(input.GetCount()-1);
  }
};


Well, this obviously has to crash for some values of q.... Like < 100
Previous Topic: Uppercase in EditField and cursor position
Next Topic: How to toggle on/off word wrap in LineEdit/DocEdit?
Goto Forum:
  


Current Time: Fri Mar 29 12:10:26 CET 2024

Total time taken to generate the page: 0.01164 seconds