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 » U++ Widgets - General questions or Mixed problems » Extending EditString to filter keys
Re: Extending EditString to filter keys [message #31170 is a reply to message #31168] Fri, 11 February 2011 14:08 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Jeremi,

There is a litle bit simpler way. All the U++ edit fields based on EditField have a method SetConvert(const Convert&), which allows to handle how seting and retrieving values work and, most importantly for you, it allows to filter which characters are alowed.

All you need to do is to create a class inherited from Convert and override its Filter method. The code could be something simple such as:
class MyConvert:public Convert{
public:
    virtual int Filter(int chr){
        return IsAlpha(chr)?chr:0; //return 0 if we want to discard the character
    }
};

Then you can use it as myeditstring.SetConvert(MyConvert()) and it will filter out all characters except letters. For full description of Convert have a look in manual. Nice examples can be found Core/Convert.{h,cpp}.

Best regards,
Honza

PS: I wrote it from top of my head, hopefully there are no big mistakes... Smile
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Focus without selecion
Next Topic: Modern looking U++ controls
Goto Forum:
  


Current Time: Thu May 16 01:05:47 CEST 2024

Total time taken to generate the page: 0.02802 seconds