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

Radwindow + Focus

3 Answers 84 Views
Window
This is a migrated thread and some comments may be shown as answers.
erawan
Top achievements
Rank 1
erawan asked on 18 Aug 2010, 03:30 PM
Hi,

is it possible to make losing focus programatically on a window?

like this:

window1.GotFocus += new routedeventhandler(window1_GotFocus);
window2.GotFocus += new ...( window2_GotFocus);


void window1_GotFocus(...)
{
// lose window2 focus
}


void window2_GotFocus(...)
{
// lose window1 focus
}


Because right now, I have 2 Radwindow, but when I have focus on one and when I click on the other I don't lose the focus of the first RadWindow. How I know that? Because I have this code:

window1.GotFocus += new routedeventhandler(window1_GotFocus);
window1.LostFocus += new routedeventhandler(window1_LostFocus);
window2.GotFocus += new routedeventhandler( window2_GotFocus);

window2.LostFocus += new routedeventhandler(window2_LostFocus);

void window1_GotFocus(object sender, routedeventargs e)
{
            var window = sender as RadWindow;
            if (window != null && window.IsActiveWindow)
            {
                mytextblos.Text += "\ngot focus fenetre 1";
               
            }
}

void window1_LostFocus(object sender, routedeventargs e)
{
            var window = sender as RadWindow;
            if (window != null && !window.IsActiveWindow)
            {
                mytextblos.Text += "\nLostfocus fenetre 1";
               
            }
}

void window2_GotFocus(object sender, routedeventargs e)
{
            var window = sender as RadWindow;
            if (window != null && window.IsActiveWindow)
            {
                mytextblos.Text += "\ngot focus fenetre 2";
               
            }
}

void window2_LostFocus(object sender, routedeventargs e)
{
            var window = sender as RadWindow;
            if (window != null && !window.IsActiveWindow)
            {
                mytextblos.Text += "\nLostfocus fenetre 2";
               
            }
}

but sometimes the "lostfocus fenetre i" doesn't work.....

Please help !

Erawan

3 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 20 Aug 2010, 08:45 AM
Hello Erawan,

 When the focus is moved to another window, the one that owned the focus previously looses it first and then the new owner receives it. Please refer to the attached example that demonstrates this behavior.

Please let me know if I don't understand the issue correctly.

Regards,
Miroslav Nedyalkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
erawan
Top achievements
Rank 1
answered on 20 Aug 2010, 11:16 AM
Thanks a lot.

But I tried your code. It works no pb.

But when I try to call any function, I lost the focus on the window.

My code:

window1.GotFocus += new RoutedEventHandler(window1_GotFocus);
window1.LostFocus += new RoutedEventHandler(window1_LostFocus);

window2.GotFocus += new RoutedEventHandler(window2_GotFocus);
window2.LostFocus += new RoutedEventHandler(window2_LostFocus);


void window1_GotFocus(object sender, RoutedEventArgs e)
{
var window = sender as RadWindow;
events.Items.Add("got focus window1")
window.Style = window.Resources["SecondStyle"] as Style;
}

void window1_LostFocus(object sender, RoutedEventArgs e)
{
var window = sender as RadWindow;
events.Items.Add("lost focus window1")
window.Style = window.Resources["FirstStyle"] as Style;
}


void window2_GotFocus(object sender, RoutedEventArgs e)
{
events.Items.Add("got focus window2")
}

void window2_LostFocus(object sender, RoutedEventArgs e)
{
events.Items.Add("lost focus window2")
}




where FirstStyle and SecondStyle are 2 styles that I created.
and when I click on the firstwindow, I got the focus, but I lose it :

got focus window1 ( clicking window1)
lost focus window1

got focus window2 ( clicking window2)

lost focus window2 ( clicking window1)
got focus window1
lost focus window1
0
George
Telerik team
answered on 25 Aug 2010, 01:06 PM
Hi Erawan,

If you want to change the style for the RadWindow when is focused and when it's not, I suggest you to create states instead of setting styles.

I hope this helps.

Greetings,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
erawan
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
erawan
Top achievements
Rank 1
George
Telerik team
Share this question
or