How to override default action with my own? (1 Viewer)

pilehave

Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    Hi

    I have a plugin that I want to perform some of my own action instead of the default action.

    Say, I catch the user pressing record. Now, instead of showing the normal "Do you wish to record", I want to give the user other options in another window.

    Is there any way to let my plugin take the userinput and stop the default code from excecuting?

    A small test like this one below, shows that my script is never excecuted (the log doesn't have an entry for "PowerPlay"), because there already is a function bound to the record-button of my remote:

    Code:
    public void OnAction(MediaPortal.GUI.Library.Action action)
            {
                switch (action.wID)
                {
                    case MediaPortal.GUI.Library.Action.ActionType.ACTION_RECORD:
                        //stopRecordingDialog();
                        Log.Info("PowerPlay - user pressed record");
                    break;
                }
            }

    What I would like to do is to override the play, record and stop-button in the fullscreen-tv window. That's all :)

    I have the code behind these three buttons working, but right now I can only map them to keys on my keyboard that is not being used, or buttons on my remote that is also not being used. Not very userfriendly of me to release the plugin like that ;)
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #2
    Further investigation suggest that my function actually does get excecuted, but the GUI Dialog is hidden as soon it is shown, because the built-in action (in this case whatever happens when you press "r" on your keyboard), is called.

    Code:
            //Just testing...
            private void mytest()
            {
                try
                {
                  GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                  if (pDlgOK == null) return;
                    pDlgOK.Reset();
                    pDlgOK.SetHeading("meh");//my tv
                    Log.Info("PowerPlay - test 2 ok");
                    pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
                    Log.Info("PowerPlay - test 3 ok");
                    
    
    
                }
                catch (Exception ex)
                {
                    Log.Error("PowerPlay - Error(3): " + ex.Message + "( " + ex.StackTrace + " )");
                }
            }

    This code example works if i I fire it with a key that does not have a built-in fuction mapped to it, in my case the danish characters æ,ø and å are all free, and with these it works (shows the dialog).

    Both "PowerPlay - test 2 ok" and "PowerPlay - test 3 ok" is logged:

    Code:
    2008-09-14 22:15:01.500000 [Info.][MPMain]: PowerPlay - test 2 ok
    2008-09-14 22:15:01.500000 [Debug][MPMain]: WindowManager: route TvPlugin.TvFullScreen:602->MediaPortal.Dialogs.GUIDialogOK:2002
    2008-09-14 22:15:01.515625 [Debug][MPMain]: Window: MediaPortal.Dialogs.GUIDialogOK init
    2008-09-14 22:15:01.531250 [Debug][MPMain]: WindowManager: unroute to MediaPortal.Dialogs.GUIDialogOK:2002->TvPlugin.TvFullScreen:602
    2008-09-14 22:15:01.531250 [Debug][MPMain]: WindowManager: route TvPlugin.TvFullScreen:602->MediaPortal.Dialogs.GUIDialogMenuBottomRight:2015
    2008-09-14 22:15:01.546875 [Debug][MPMain]: Window: MediaPortal.Dialogs.GUIDialogMenuBottomRight init
    //
    //Lines with debug and info cut from here, as they are not important
    //
    2008-09-14 22:15:03.265625 [Info.][MPMain]: PowerPlay - test 3 ok

    So...it's still a matter of overriding the dialog that would normally show. Any suggestions? Please?
     

    Users who are viewing this thread

    Top Bottom