@@ -178,6 +178,11 @@ class STB_OT_RemoveButton(Operator):
178178 default = True
179179 )
180180
181+ @classmethod
182+ def poll (cls , context : Context ):
183+ STB_pref = get_preferences (context )
184+ return STB_pref .selected_button != ""
185+
181186 def draw (self , context : Context ):
182187 STB_pref = get_preferences (context )
183188 layout = self .layout
@@ -221,6 +226,11 @@ class STB_OT_Load(Operator):
221226 name = "Texts in Texteditor"
222227 )
223228
229+ @classmethod
230+ def poll (cls , context : Context ):
231+ STB_pref = get_preferences (context )
232+ return STB_pref .selected_button != ""
233+
224234 def draw (self , context : Context ):
225235 layout = self .layout
226236 layout .prop (self , 'mode' , expand = True )
@@ -277,6 +287,11 @@ class STB_OT_Reload(Operator):
277287 bl_description = "Reload the linked Text in the Texteditor of the selected Button"
278288 bl_options = {"REGISTER" }
279289
290+ @classmethod
291+ def poll (cls , context : Context ):
292+ STB_pref = get_preferences (context )
293+ return STB_pref .selected_button != ""
294+
280295 def execute (self , context : Context ):
281296 STB_pref = get_preferences (context )
282297 stb = context .scene .stb
@@ -315,6 +330,11 @@ class STB_OT_Save(Operator):
315330 bl_label = "Save"
316331 bl_description = "Save all buttons to the Storage"
317332
333+ @classmethod
334+ def poll (cls , context : Context ):
335+ STB_pref = get_preferences (context )
336+ return STB_pref .selected_button != ""
337+
318338 def execute (self , context ):
319339 Fails = []
320340 for button in context .scene .stb :
@@ -395,6 +415,11 @@ def get_use_filter_folder(self):
395415 filepath : StringProperty (name = "File Path" , maxlen = 1024 , default = "" )
396416 directory : StringProperty (name = "Folder Path" , maxlen = 1024 , default = "" )
397417
418+ @classmethod
419+ def poll (cls , context : Context ):
420+ STB_pref = get_preferences (context )
421+ return STB_pref .selected_button != ""
422+
398423 def draw (self , context : Context ):
399424 layout = self .layout
400425 layout .prop (self , 'mode' , expand = True )
@@ -441,6 +466,11 @@ class STB_OT_Import(Operator, ImportHelper):
441466 )
442467 files : CollectionProperty (type = PropertyGroup )
443468
469+ @classmethod
470+ def poll (cls , context : Context ):
471+ STB_pref = get_preferences (context )
472+ return STB_pref .selected_button != ""
473+
444474 def execute (self , context : Context ):
445475 not_added_file = []
446476 button_fails = ([], [])
@@ -519,6 +549,11 @@ class STB_OT_Edit(Operator):
519549 name : StringProperty (name = "Name" )
520550 stb_properties : CollectionProperty (type = properties .STB_edit_property_item )
521551
552+ @classmethod
553+ def poll (cls , context : Context ):
554+ STB_pref = get_preferences (context )
555+ return STB_pref .selected_button != ""
556+
522557 def items_stb_select_area (self , context : Context ):
523558 for item in self .stb_areas :
524559 if item .delete :
@@ -679,6 +714,11 @@ class STB_OT_LoadSingleButton(Operator):
679714 bl_label = "Load Button"
680715 bl_description = "Load the script of the selected Button into the Texteditor"
681716
717+ @classmethod
718+ def poll (cls , context : Context ):
719+ STB_pref = get_preferences (context )
720+ return STB_pref .selected_button != ""
721+
682722 def execute (self , context : Context ):
683723 STB_pref = get_preferences (context )
684724 stb = context .scene .stb
@@ -717,6 +757,11 @@ def text_properties_items(self, context):
717757 options = {'HIDDEN' }
718758 )
719759
760+ @classmethod
761+ def poll (cls , context : Context ):
762+ STB_pref = get_preferences (context )
763+ return STB_pref .selected_button != ""
764+
720765 def invoke (self , context : Context , event : Event ):
721766 STB_pref = get_preferences (context )
722767 text_index = bpy .data .texts .find (STB_pref .selected_button )
@@ -754,7 +799,9 @@ def execute(self, context: Context):
754799 item = self .text_variables [index ]
755800 lines = [line .body for line in text .lines ]
756801 if self .space == "PanelDialog" :
757- insert_comment = f"#STB-Input-Panel-{ item .type } /// #STB-Input-Dialog-{ item .type } /// #STB-InitValue-{ item .value } -END"
802+ insert_comment = (
803+ f"#STB-Input-Panel-{ item .type } /// #STB-Input-Dialog-{ item .type } /// #STB-InitValue-"
804+ + f"{ item .value } -END" )
758805 else :
759806 insert_comment = f"#STB-Input-{ self .space } -{ item .type } /// #STB-InitValue-{ item .value } -END"
760807 lines .insert (item .position , insert_comment )
0 commit comments