Unable to clear label of ControlButton
#1
Hi,

In my script addon (Rom Collection Browser) I provide a settings screen similar to the builtin addon settings screen. For simple text settings I use a label with the name of the setting and a button that displays the value of the setting. When the user clicks the button I open a keyboard dialog and update the button label with the text entered. This works fine IF the user enters text. When the user wants to clear the present text this does NOT work.

In the addon I use the following code:
Code:
keyboard = xbmc.Keyboard()
keyboard.setHeading(util.localize(40032) %name)            
keyboard.setDefault(textValue)
keyboard.doModal()
if (keyboard.isConfirmed()):
    textValue = keyboard.getText()

control.setLabel(textValue)

Problem is that ControlButton.setLabel("") will not work. The reason is simple, here is the beginning of ControlButton:ConfusedetLabel in xbmc/interfaces/legacy/Control.cpp:
Code:
void ControlButton::setLabel(const String& label,
                                 const char* font,
                                 const char* _textColor,
                                 const char* _disabledColor,
                                 const char* _shadowColor,
                                 const char* _focusedColor,
                                 const String& label2) throw (UnimplementedException)
{
  if (!label.empty()) strText = label;
  ...
}

Is there any reason why this is checked for empty text? Or is there any workaround to solve this?

Right now I could check for empty strings and replace them with a whitespace or I could add the name of the setting to the button label and extract it to get the value of the setting. But this does not feel right.

Any ideas?

Regards,
malte
Reply

Logout Mark Read Team Forum Stats Members Help
Unable to clear label of ControlButton0