SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   SH5 Mods Workshop (https://www.subsim.com/radioroom/forumdisplay.php?f=249)
-   -   [REQ] How Add an Event in Python (https://www.subsim.com/radioroom/showthread.php?t=164582)

AOTD_Rhonen 03-12-10 03:13 PM

[REQ] How Add an Event in Python
 
Hi guys,

anyone can help me by adding an Event on a Button?
Code:

def InitializeScript():
   
    Show = False
    Pagerecognitionmanual_Recmanual_Unit.Visible=False
    Pagerecognitionmanual_Recmanual_Criticalzones.Visible=False
    Pagerecognitionmanual_Recmanual_Cover.Visible=False
    Pagerecognitionmanual_Recmanual_Openbook.Visible= True
    SetReconEvents()
   
    #pass

def SetReconEvents():
    ScriptManagerManaged.ShowPythonError("SETEVENTs")
    Pagerecognitionmanual_Recmanual_Cover_Close.MouseLeftButtonClicked += OpenCloseManual
    Pagerecognitionmanual_Recmanual_Openbook_BtnOpen.MouseLeftButtonClicked += OpenCloseManual
    #pass

def OpenCloseManual():
    ScriptManagerManaged.ShowPythonError("EVENT")

So i get my Initialize and i get my Message on SetReconEvents()

But if i click on the BtnOpen ingame, nothing happens... so OpenCloseManual() is not handled ... Any Ideas?

And yes, i am working on the Reconitionmanual.
Both, Pagerecognitionmanual_Recmanual_Cover_Close.MouseL eftButtonClicked and Pagerecognitionmanual_Recmanual_Openbook_BtnOpen are Buttons

TheDarkWraith 03-12-10 03:18 PM

Quote:

Originally Posted by AOTD_Rhonen (Post 1311327)
Hi guys,

anyone can help me by adding an Event on a Button?
Code:

def InitializeScript():
 
    Show = False
    Pagerecognitionmanual_Recmanual_Unit.Visible=False
    Pagerecognitionmanual_Recmanual_Criticalzones.Visible=False
    Pagerecognitionmanual_Recmanual_Cover.Visible=False
    Pagerecognitionmanual_Recmanual_Openbook.Visible= True
    SetReconEvents()
 
    #pass
 
def SetReconEvents():
    ScriptManagerManaged.ShowPythonError("SETEVENTs")
    Pagerecognitionmanual_Recmanual_Cover_Close.MouseLeftButtonClicked += OpenCloseManual
    Pagerecognitionmanual_Recmanual_Openbook_BtnOpen.MouseLeftButtonClicked += OpenCloseManual
    #pass
 
def OpenCloseManual():
    ScriptManagerManaged.ShowPythonError("EVENT")

So i get my Initialize and i get my Message on SetReconEvents()

But if i click on the BtnOpen ingame, nothing happens... so OpenCloseManual() is not handled ... Any Ideas?

And yes, i am working on the Reconitionmanual.
Both, Pagerecognitionmanual_Recmanual_Cover_Close.MouseL eftButtonClicked and Pagerecognitionmanual_Recmanual_Openbook_BtnOpen are Buttons

for the control you want to add an event to use this syntax:

control.action += name of function to call

where control = the name of the control (i.e. Pagelayout_Groupfeedback)
action = the action the user did (i.e. MouseIn, MouseOut, MouseLeftButtonClicked, etc.)

AOTD_Rhonen 03-12-10 03:24 PM

ok, i will recheck whats wrong.

thanks

TheDarkWraith 03-12-10 03:35 PM

Quote:

Originally Posted by AOTD_Rhonen (Post 1311354)
ok, i will recheck whats wrong.

thanks

ensure you unload the event when you're script is done (in unloadscript)

AOTD_Rhonen 03-12-10 03:50 PM

ok, i will add the Lines :)


All times are GMT -5. The time now is 03:45 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.