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 » Community » Newbie corner » Filtering CR from an EditString
Filtering CR from an EditString [message #45120] Mon, 07 September 2015 00:08 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I am having a problem filtering the user input in an EditString field.

The usage scenario of the application is the following:
-The user has a job order sheet with a bar code printed on it (the bar code contains a simple alphanumeric code in the form "1599991090");
-Using a bar code reader, the user enters the code in the EditString;
-When the code is entered, the application should elaborate the code (i.e. divide it in different "chunks": "1599991090" is divided in three different fields, "15999", "10" and "90") and save them in a db with the current time.

The problem is that the bar code reader puts two CR at the end of the string, so the result is:
-the code is entered;
-the focus goes to the next field (first CR);
-a button is pressed (second CR).

This is not the intended behaviour, so I would like to "intercept" the user input before the focus goes to the second field, remove the CR and elaborate the input. I think that the solution to my problem could be in this thread http://www.ultimatepp.org/forums/index.php?t=msg&th=587& amp;start=0& here, but I do not know how to tell upp that the character I want to filter is a CR. I have also problem to tell upp what should be the "active" button, I tried .SetFocus but it does not seem to work. I can not test the code right now, because I am on a friend's pc.

Thanks for any help,
Giorgio
Re: Filtering CR from an EditString [message #45126 is a reply to message #45120] Tue, 08 September 2015 11:29 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi Giorgio,

I think changing setup of bar code scanner may be right solution.

Check setup. It will be possible to stop additional characters sent by scanner in scanner setup.

There is normally provision in scanner setup to add Prefix and Suffix chars.

Most likely double "CR" is added as suffix.




Warm Regards

Deepak

[Updated on: Tue, 08 September 2015 11:29]

Report message to a moderator

Re: Filtering CR from an EditString [message #45128 is a reply to message #45126] Wed, 09 September 2015 11:35 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Actually that was the simplest and quickest way Smile
Re: Filtering CR from an EditString [message #49465 is a reply to message #45128] Thu, 15 February 2018 10:21 Go to previous message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
any way, you can filter CR from the EditString (edit) :
edit.SetFilter(
      [](int k){ 
            if (k == '\r') return 0; 
            return k;
           }
    );


regards
omari.
Previous Topic: LocalProcess2 doesnt show child app window (it is running)
Next Topic: From std::string to String
Goto Forum:
  


Current Time: Fri Mar 29 00:44:19 CET 2024

Total time taken to generate the page: 0.03492 seconds