View Single Post
Old 03-25-11, 04:16 AM   #236
MiTon
Sparky
 
Join Date: Apr 2010
Location: Germany
Posts: 157
Downloads: 270
Uploads: 2
Problem triggering action with new button!

Hello!

I hope it's the right place to ask, but I've got a problem triggering an action from a new checkbox. Maybe someone can help?

Here the situation:

To toggle SpeechRecognition on/off I created a new checkbox with the MenuEditor.
Located above the PageDefaultHud_Feedback_BottomBar_ToggleAdvancedCk (NewUI)
It's showing ingame and I can click it.

The coressponding Lines in Page Default Hud.ini look like this:

Code:
[G0A I278]
Name=ToggleSpeechRecCk
Type=1033;Check box
ItemID=0xA1E0001
ParentID=0xA1E0000
Pos=253,-4,18,20
Zone= 255 46 18 20 0 1 0xA1E0000 0.952727 -0.29 0xA1E0001 -0.5 0.5 0 0
Materials=8
Display=2;Linear
Mat 0=data/menu/gui/layout/hud3.dds
Crop 0=0.178711,0.105469,0.0175781,0.0195313
Mat 1=data/menu/gui/layout/hud3.dds
Crop 1=0.178711,0.128906,0.0175781,0.0195313
Mat 2=data/menu/gui/layout/hud3.dds
Crop 2=0.178711,0.105469,0.0175781,0.0195313
Mat 3=data/menu/gui/layout/hud3.dds
Crop 3=0.178711,0.128906,0.0175781,0.0195313
Mat 4=data/menu/gui/layout/hud3.dds
Crop 4=0.178711,0.105469,0.0175781,0.0195313
Mat 5=data/menu/gui/layout/hud3.dds
Crop 5=0.178711,0.128906,0.0175781,0.0195313
Mat 6=data/menu/gui/layout/hud3.dds
Crop 6=0.178711,0.105469,0.0175781,0.0195313
Mat 7=data/menu/gui/layout/hud3.dds
Crop 7=0.178711,0.128906,0.0175781,0.0195313
MatFlags=0x9
TexFmt=0x0
Font=21
Text=0
TextPosFlags=0x2
TextOffsetY=8,8,8,8
TextFlags=0x0
CheckBoxWidth=0
StatesColors=0xCDBEB4FF, 0xCDBEB4FF, 0xCDBEB4FF, 0xCDBEB4FF
In Page Default Hud.py I added the these lines (the ... arent' there )

Code:
from SpeechRecognition import ToggleSpeechRecognitionOnOff

...

def PageDefaultHud_Feedback_BottomBar_ToggleSpeechRecCk_Clicked():
    ToggleSpeechRecognitionOnOff()

...

def InitializeScript():

....

PageDefaultHud_Feedback_BottomBar_ToggleSpeechRecCk.Clicked += PageDefaultHud_Feedback_BottomBar_ToggleSpeechRecCk_Clicked

...

def UnloadScript():

...

PageDefaultHud_Feedback_BottomBar_ToggleSpeechRecCk.Clicked -= PageDefaultHud_Feedback_BottomBar_ToggleSpeechRecCk_Clicked
Now I' getting namespace errors:


So what went wrong importing Speech Recognition.py???

Called from Speech Recognition.py the command is working like expected!

What's the minimum of code needed for a new button like this? What did I miss?

What would be needed if I wan't to add a new group?

Thanks in advance!

Greets

MiTon

Last edited by MiTon; 03-25-11 at 05:08 AM.
MiTon is offline   Reply With Quote