This is a migrated thread and some comments may be shown as answers.

RadLabel Always Capture Key Events

2 Answers 94 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vinicius
Top achievements
Rank 1
Vinicius asked on 09 Jul 2012, 11:43 PM
Hi,
I have an application using RadControls for WinForms C# (v.2012.1.321.20) and I got some issues with RadLabels. There's a RadPanel capturing Key-Up Events and 2 RadLabels above the panel just to show some information about the key pressed (labels dont capture any event, just the panel all the time), and it works fine except for the 4 navigation keys: Up,Down,Left and Right. When one of those keys is pressed the panel miss it twice, and just on the third time the panel get the event. It looks like the navigation key is changing the focus between these 2 labels and the panel, and I tried a lot of things to avoid this like:

- Set label's "Focusable" property to false;
- Create an "Preview KeyDown" event that set focus on RadPanel before the KeyUp event is handled;

Nothing fixed it out and radlebels still getting Key-Up events instead of RadPanel, so I would like to know if there's any solution for this issue (because it's not happening with others controls above the panel like Microsoft Label Control).

Thanks!

2 Answers, 1 is accepted

Sort by
0
Vinicius
Top achievements
Rank 1
answered on 09 Jul 2012, 11:48 PM
One more information: I tried to disable the RadLabels (Enable=false) and it worked fine, but I can't change the font color or appareance in disabled control. If i would change the font color of disabled label (looking like enabled) it would be fine in my application.
0
Stefan
Telerik team
answered on 12 Jul 2012, 01:37 PM
Hi Vinicius,

Thank you for writing.

In order to be able to catch the KeyUp of event of a key, it should be InputKey. Arrow keys by default are considered as system keys, thus you are not able to catch their KeyUp event. To allow that, you need to create a descendant of RadPanel, override its IsInputKey method and return true if arrow key is pressed. In the example below, I am returning true in all cases in order to get the KeyUp event for every possible key:
class MyPanel : RadPanel
{
    protected override bool IsInputKey(Keys keyData)
    {
        return true;
    }
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadPanel).FullName;
        }
    }
}

I hope this helps.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
General Discussions
Asked by
Vinicius
Top achievements
Rank 1
Answers by
Vinicius
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or