Questions about onKeyPress

View: New views
3 Messages — Rating Filter:   Alert me  

Questions about onKeyPress

by Feng Feng :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello all,

I want to allow the user only to enter at most 6 characters in the cell of table.
Here is my implementation:

// class PlanPointTable : public FXTable
long PlanPointTable::onKeyPress(FXObject *sender, FXSelector sel, void* ptr)
{
        ...
        FXTableItem *item = getItem(current.row, current.col);
        FXString str = item->getText();

        if (str.length() > 5)
       {
            // do nothing
           return 1;
        }

        ...
        return 1;
}

The problem is that during the entering procedure, the returned value of the str is always EMPTY
until I press ENTER key.

Is there a method that I can get the entered text in the cell on real time?

Thank you


------------------------------------------------------------------------------

_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: Questions about onKeyPress

by Jeroen van der Zijp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 25 June 2009, Feng Feng wrote:

> Hello all,
>
> I want to allow the user only to enter at most 6 characters in the cell of table.
> Here is my implementation:
>
> // class PlanPointTable : public FXTable
> long PlanPointTable::onKeyPress(FXObject *sender, FXSelector sel, void* ptr)
> {
>         ...
>         FXTableItem *item = getItem(current.row, current.col);
>         FXString str = item->getText();
>
>         if (str.length() > 5)
>        {
>             // do nothing
>            return 1;
>         }
>
>         ...
>         return 1;
> }
>
> The problem is that during the entering procedure, the returned value of the str is always EMPTY
> until I press ENTER key.
>
> Is there a method that I can get the entered text in the cell on real time?

If you're editing the item with FXTextField, you can set TEXTFIELD_LIMITED and
pass the desired number of columns.

Note that the length of the string is the number of bytes, but the number of characters
may be less than the number of bytes because of the UTF-8 unicode representation; in UTF-8
characters may be 1, 2, 3, or 4 bytes. (the actual representation goes up to 6 but technically
there are no code points above 1,114,112 so 4 bytes is enough).

Use string.count() to figure out how many unicoce characters are in the string...


                - Jeroen



------------------------------------------------------------------------------
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: Questions about onKeyPress

by Feng Feng :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello Jeroen,

> Is there a method that I can get the entered text in the cell on real time?

||||If you're editing the item with FXTextField, you can set TEXTFIELD_LIMITED and
||||pass the desired number of columns.

Yes, I use the default FXTableItem which in turn uses FXTextField.

The original FXTableItem controls the input through getControlFor and setFromControl.

Where and how should I add the TEXTFIELD_LIMITED to control the number of unicode string that can be entered into the FXTextField?


Thank you
Feng





------------------------------------------------------------------------------

_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users