On focus and new windows? (1 Viewer)

keith2045

Portal Pro
February 16, 2006
264
2
Missouri
Home Country
United States of America United States of America
I'm creating my first MP plugin and have a few questions. Please note, i'm new at c# programming, so go easy on me :).

I've got alot of the backend stuff programed, now i'm working on the GUI within MP. First how do i capture an on focus event? I need to update some text based on what is focused.

Also I've got the main screen down, when a user clicks on a button i want to take them to a different screen, how do i do this? I can get the button click, just dont know what to do after that. Currently (just for testing), i'm setting all of the controls to nonvisible and enabling the ones i want visible. The problem with that is if the user hits esc it takes them out of my plugin completely.

Thanks in advance
 

joz

Portal Pro
March 17, 2008
1,353
306
Home Country
Netherlands Netherlands
Also I've got the main screen down, when a user clicks on a button i want to take them to a different screen, how do i do this
Buttons have two ways of doing this;
- Hyperlink tag;
I think this can only take you to a different plugin all together

- Action tag;
Perform an action received by C# code to do something in the same window. How this all works from C# side I do not know
 

keith2045

Portal Pro
February 16, 2006
264
2
Missouri
Home Country
United States of America United States of America
I dont really want to open a different plugin, just a different screen for my plugin. The only way that i know of is to set all of the controls to nonvisible and set the ones that i want to display as visible. But when i do that when the user hits esc it takes them out of the plugin completely and not back to the other screen.
 

joz

Portal Pro
March 17, 2008
1,353
306
Home Country
Netherlands Netherlands
I know My Trailers does what you want it to do, maybe you can dive into some source. Well kinda, it actually uses listcontrols to jump from one window to the other;
https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/MyTrailersNew/

All svn plugin source overview;
https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/

looking @ the xml of My Trailers it seems like it hides controls, like you described. However My Trailers does not experience the problem with the "esc" key.
 

moiristo

Portal Pro
November 17, 2006
342
27
Enschede
Home Country
Netherlands Netherlands
Somewhere in my plugin I activate a new window with its own ID and skin file. Pressing back takes you back to the old window. It's as easy as calling:
Code:
GUIWindowManager.ActivateWindow(6801);

To make this work, you need to create another GUIWindow class with the specified ID:

Code:
public class Window2: GUIWindow {
        public override int GetID
        {
            get { return 6801;  }
            set { base.GetID = value; }
        }

        public override bool Init()
        {
            return Load(GUIGraphicsContext.Skin + @"\window2.xml");
        }

         ...
}

Check out the TVGemist plugin from the plugins SVN for the actual code (NLGemist.cs, NLGemistEmissionInfo.cs)
 

Users who are viewing this thread

Top Bottom