Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Extending EditString to filter keys
Extending EditString to filter keys [message #31168] |
Fri, 11 February 2011 11:54  |
Jeremi
Messages: 3 Registered: February 2011 Location: spain
|
Junior Member |
|
|
Hi all
I am a beginner in Upp. Very cool lib!!
I am trying to make an edit control to acept only letters (a-z and A-Z) so I extended a new class from EditString and i am trying to implement it, like this:
#ifndef _MYEDIT_h
#define _MYEDIT_h
#include <CtrlLib/CtrlLib.h>
using namespace UPP;
class MyEditString : public EditString
{
public:
typedef MyEditString CLASSNAME;
MyEditString();
~MyEditString();
virtual bool Key(dword key, int repcnt);
private:
};
#endif
--------------------------
#include "MyEditString.h"
MyEditString::MyEditString()
{
}
MyEditString::~MyEditString()
{
}
bool MyEditString::Key(dword key, int repcnt)
{
if(key == K_F)
{
Exclamation("f was pressed")
return true;
}
return EditString::Key(key, repcnt);
}
Then I added a EditString to a dialog and change its type from EditString to MyEditString (now just to detect the F and prevent it from appearing in edit box!)
It works. It detects f and it prevents it from appearing in the edit box but if I remove the Exclamation the f appears in the edit box.
I thought that when the return true we are saying that the event is already handled, but returning true the f appears and I want to prevent it from appear.
Any help?
Thank to all of you
Jeremi
|
|
|
Goto Forum:
Current Time: Sat Apr 26 17:30:05 CEST 2025
Total time taken to generate the page: 0.00914 seconds
|