logixoul's picture

GameWindow.FocusedChanged should have a bool saying whether we *received* or *lost* focus

GameWindow.FocusedChanged provides no info in its EventArgs, which means I need to check this.Focused to know whether I received focus or lost focus. This is inconsistent with other events such as MouseDevice.Move. I think the EventArgs of FocusedChanged should have a "bool GotFocus". Either that, or FocusedChanged should be split into GotFocus and LostFocus.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Why duplicate information that's trivially available already?

FocusedChanged += (sender, e) =>
{
   Console.WriteLine("Focus {0}", Focused ? "received" : "lost ");
};
logixoul's picture

Well, I think it's .NET convention to put all event-related data in the EventArgs, so it's what I expected when I was coding using GameWindow. If you don't see it that way though, no problem.

the Fiddler's picture

Actually, I've tried to follow the BCL conventions as far as possible (not 100%, since much of the code was written before I was even aware of them). In the case of FooChanged events, the convention appears to avoid repeating the value of Foo inside the event. For instance Control.ParentChanged:

public void ParentChanged(object sender, EventArgs e)

I don't if there is an official convention for this, but all FooChanged events I've checked seem to conform to this pattern.

logixoul's picture

Yep. You're right.