Closed Sappharad closed 9 years ago
Just an update, because I better understand the problem now.
With the code snippet above, I was modifying your "Eto in MonoMac" example that embeds an Eto panel with controls into a native window. Your Custom Field Editor to trap the LostFocus event is created at the Window level, which won't exist here because the window wasn't created by you.
However, the project I produced the problem in initially is creating the Window directly in Eto, but the control I'm trying to attach the event to is several levels deep instead a programmatically added custom control that extends the TextBox. For some unknown reason, it doesn't get the custom field editor so it just throws LostFocus as soon as GotFocus occurs, so I never know when it actually gains or loses focus. It may be the result of several custom panels as parents, but I'm not sure yet.
Any good ideas would be appreciated. I'm not sure if this can be considered a bug anymore, but it's definitely not desired behavior and I don't know how I'm going to get this working yet.
Have you tried the develop branch? I believe this is fixed.
but the control I'm trying to attach the event to is several levels deep instead a programmatically added custom control that extends the TextBox
Not sure what you mean by this.. If you mean you've inherited Eto's TextBox, that should be fine. If you can make a little repro of the issue I can take a look, if the develop branch doesn't fix it for you.
Cheers! Curtis.
That's exactly what I meant.
And unfortunately, I am working from the develop branch already. I'll make a small sample project that reproduces the problem.
interesting since the MaskedTextBox relies on the LostFocus event to hide the mask when the text box loses focus. I'll wait for the sample, perhaps there's something with how the form is put together on why it isn't working.
I made a stripped-down sample project, and it works correctly there. You're right, it's how the form is put together. The fact that I picked the wrong sample to try and re-produce the problem in did not help.
The form in question has the key down event overridden to set e.Handled to true on all of the text boxes such that pressing keys will not type text into them. The reason for this is that I'm using OpenTK's Keyboard class to read the raw input from keyboards and gamepads and set the text in the field appropriately. (It's a button configuration window.)
I'm guessing that OpenTK Input must be interfering with the Custom Field Editor somehow. I'll try to change things to use something other than a text field instead. Sorry to waste your time.
I'll leave this open in case you have any additional advice, if not, feel free to close it.
(It's not a sample, but if you want to see the full code it's in the project at https://github.com/TASVideos/BizHawk/tree/mono-portable/BizHawk.Client.EtoHawk The window is in Config/ControllerConfig.cs)
I'll probably file some actual legit bugs in the future, or fix them myself and submit pull requests, since I've run into a few on the way already.
Thanks for making this framework!
Going to take a different approach.
Great, thanks for confirming that it wasn't an issue with Eto directly. If there's anything that can be done in Eto to make it better integrate with what you're doing, feel free to submit an issue. I'd like to make sure Eto works great when combined with other frameworks as well.
Cheers! Curtis.
The LostFocus event for a TextBox does not fire ever on OS X, at least on 10.10 and 10.11. (Have not tested older releases)
I found the following StackOverflow post which describes a similar problem in Objective C: http://stackoverflow.com/questions/3192905/nstextfield-not-noticing-lost-focus-when-pressing-tab The second solution appears to suggest exactly what you're doing in Eto, using a Custom field editor. But since it's not working, I tried to implement the top solution, adding AddMethod(selControlTextDidEndEditing, new Action<IntPtr, IntPtr, IntPtr>(TriggerLostFocusText), "v@:@"); to the LostFocusEvent in MacText.cs.
But that doesn't work either, it still won't fire. I'm not too familiar with the binding to Objective C stuff in Mono, so my attempt may have been wrong.
Any ideas how to get this working? Sample code to reproduce the problem:
This is just a modification to one your examples to hook up the events. The label will never change to Lost Focus, because the event will never fire.