- Home /
OpenFileDialog without losing focus afterwards
Hi
I am using System.Windows.Forms from Mono (I think) to call OpenFileDialog. But after I call the OpenFileDialog. It will not return to the original window. Here's my simplistic code for calling OFD:
var ofd : System.Windows.Forms.OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
ofd.Title = "Select Music file";
ofd.Filter = "MP3 Audio (*.mp3)| *.mp3|OGG Vorbis (*.ogg)|*.ogg";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK){
Debug.Log(ofd.FileName);
Is there a way to keep the gameWindow (In fullscreen) in focus after OFD?
Is something wrong with my question, or nobody can solve this?
Have you checked EditorUtility
class? e.g. OpenFilePanel
, SaveFilePanel
@frarees Yes, but I need the OpenFileDialog during Runtime.
I think you'll have to write your own using a combination of the following:
I'm having the same problem calling Native $$anonymous$$ac OS X file dialogs. I can see why it's an issue, the native focus manager has to allow the key strokes needed. If I take it out of full screen mode, switch another app, tap a key, then switch back, I get the focus again. Need to call something that the Unity is managing I think. Oddly enough, the arrow keys work - focus isn't lost for them, just the rest of the keyboard!