From 30235b565c531fb4f415d4d69e68667cb0030859 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Fri, 23 Aug 2024 12:28:01 +0200 Subject: [PATCH] update active_font_index if out or range --- __init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index be06943..b3a4c11 100644 --- a/__init__.py +++ b/__init__.py @@ -257,7 +257,14 @@ class ABC3D_text_properties(bpy.types.PropertyGroup): #TODO: simply, merge, cut cut cut class ABC3D_data(bpy.types.PropertyGroup): available_fonts: bpy.props.CollectionProperty(type=ABC3D_available_font, name="Available fonts") - active_font_index: bpy.props.IntProperty() + def active_font_index_update(self, context): + if len(self.available_fonts) <= self.active_font_index: + self.active_font_index = len(self.available_fonts) - 1 + + active_font_index: bpy.props.IntProperty( + default=-1, + update=active_font_index_update, + ) available_texts: bpy.props.CollectionProperty(type=ABC3D_text_properties, name="Available texts") def active_text_index_update(self, context): if self.active_text_index != -1: