07-24-2010 03:14 AM
This is probably a stupid question, but I was not able to find the trivial solution (I am pretty new to BlackBerry UI)
UI screen with two component
checkbox: "Run every day"
time field: "at hh:mm"
If checkbox is checked, time field should be enabled. If checkbox is not checked, time field should be disabled.
I was not able to find a simple solution. The workaround is to delete all components and recreate them with different style (Field.NON_FOCUSABLE | Field.READONLY), but there are major drawbacks:
Any ideas ?
Thanks in advance !
Solved! Go to Solution.
07-24-2010 04:11 AM
Some times Ago I was Also Find this solution.
But BlackBerry Does not provide Enable/ Disable Method.
But Ucan Delete Or add the controlls on the screen At runtime.
07-24-2010 07:18 PM
The way I handled this was to have custom methods in the fields that allow me to set a disabled state and then override the TouchEvent, NavigationMovement, and NavigationClick methods to check for this variable and just return true if it is set. This will take care of the FieldChanged and Focused states to make them unable to be activated.
07-25-2010 03:58 AM
Ok, subclassing components and taking care of all UI events + rendering - we need different view when component is disabled - is another approach (which I forgot to include in my original post).
This approach is also somewhat messy - at least for the rendering ...
Any other ideas ? It seems strange to not have such basic functionality in core API ...
07-25-2010 07:02 AM - edited 07-25-2010 10:39 AM
You can, for all the Fields I have ever wanted to do it on (which is not all Fields so perhaps there are Fields for which this does not work), set 'Editable'. What I have done in places, is have isFocusable() check isEditable(), and then the user can't touch the Field if they are not allowed to Edit it. I don't actually like this approach because I like to give the user to opportunity to cut/paste or at least scroll with some degree of smoothness, but sometimes it is all you need.
You can also override isEditable() to check whatever you want.
Regarding the API looking different, yes you are right, it doesn't appear (at least in Fields that I have tried) that not being editable or not being focusable changes the appearance. So you need to override paint in some way if your want to indicate this state.
07-26-2010 01:26 AM
Thanks to everybody that contributed !
I will accept one random comment as "answer" to close this thread, please don't be offended
07-26-2010 06:05 AM
Just for the record - I decided to go with system styles and partial / full screen regeneration.
Main reason is that paint cannot be customized well in some situations - for example in OS 5.0 you cannot change text color for ColorObjectChoiceField and setting global alpha damages the combo image.
07-30-2010 02:56 AM
Just for the record - if any future visitor is interested
I found a workaround for this issue:
> and setting global alpha damages the combo image.
What one needs to do is to 1. do the normal render and then 2. render alpha rect on top of the component. There is another thread regarding this approach: