xbmc/xbmc — pull request #3088 by Montellese (2013-08-09 19:44:45+00:00)
Title: CGUIEditControl: add input validation

This is an idea I had when I was working on the settings refactor. With the new settings system it is possible to get feedback on whether a value provided by the user is valid or not. Invalid values are ignored by the settings system but they are still displayed in the user interface (because it would look odd if the string just entered would automagically change itself) until the control focus is changed, at which point the value of the setting is reverted to the last valid value. Unfortunately there's no way for the user to actually know that the provided value is invalid before leaving the control.

First I just implemented the validation logic and implications in CGUIWindowSettingsCategory but then I thought it could also come in handy in other places like the smartplaylist rule editor so I tried to abstract it a bit and added the logic to set an external validation method in CGUIEditControl which will be automatically triggered whenever the value of the edit control changes. It might also make sense to be able to register a callback that is executed whenever the validity state of a control changes to be able to e.g. disable the "OK" button in the smartplaylist rule editor if the provided value is invalid.

This is more of an RFC right now because I would like to get some feedback on the general idea and approach. I first added the code to CGUIButtonControl but then thought about the possible use cases and it doesn't really make sense for radio button controls, checkboxes, spinners etc. Can anyone think of another control where this might make sense?

I would also like to get some feedback on how this could best be visualized in the user interface and what would be needed in the guilib to do that (maybe an tag and an tag?).