I am extending the ButtonField and overriding the paint method to show the buttons in a differnet color. But its painting the whole button width. Part of the button stil shows as Gray when there is no focus and blue when its on focus. Can you please help me to resolve this issue?
thanks,
ramesh
You'll have to override protected void applyTheme() to disable the extra painting that is going on.
Related
I'm using a PictureScrollField in a VerticalFieldManager with other fields that need focus. When the PictureScrollField receives focus, the images are shown in their original form. But when I remove focus, by default, the field draws a white square over the images. I looked around in the API and couldn't find a way to undo this default property. How to remove these squares?
This is the image when the field has focus-
And this is when the field loses focus-
You can see how the images have white overlays which look bad for non rectangular transparent images.
The solution is pretty simple - override onUnfocus method as
protected void onUnfocus(){
/*do nothing to prevent BB default image highlight*/
/*or do your own thing*/
}
I am having trouble with vertical scrolling on a blackberry app.
it works just fine on touch screens, but when scrolling using a track pad, it jumps from being at the top position to being at the bottom position.
Anyone had a similar problem? any idea what i could try?
Here is a snippet from my code. i have a static background image and the fields scroll on top of it:
vertical_main = new VerticalFieldManager(USE_ALL_WIDTH |NO_VERTICAL_SCROLL |USE_ALL_HEIGHT);
vertical_AllTags=new VerticalFieldManager(USE_ALL_WIDTH | VERTICAL_SCROLL);
// i then add all the fields to vertical_AllTags
vertical_main.add(vertical_AllTags);
vertical_main.invalidate();
add(vertical_main);
thanks in advance for your help
EDIT:
The suggestion of giving each field focus was correct. the only other part that needs to be done is when you override the onFocus method for a field, you need to call the super() function so that all the other normal parts of the onFocus method are still called:
protected void onFocus(int direction) {
text_select=true;
invalidate();
super.onFocus(direction);
}
protected void onUnfocus() {
text_select=false;
invalidate();
super.onUnfocus();
}
Thank you so much.
This is common issue in non touch devises for beginners.
if you want to scroll field by field there is two ways
1) you need to give the focus to all fields then it will come field by
field focus down
another way is means you dont need to focus on each and every field
2)just add the NullField after your every field and give focus to all
NullFields then your trackball will bring your screen field by field
This happends beacuse in TrackWheel Scrolling it scrolls up to the next Focused field. I think you are not give any focus between the vertical_AllTags.
You can solved this by using NullField() class. Like...
add(new NullField(Field.FOCUSABLE))
when you add add(new NullField(Field.FOCUSABLE)); you will get the null focus which is not know by you. And you can navigate all the fields like Touch Screen.
You can solve that issue by adding two vertical field manager.. take a look at the code in this post
how could i create a custom ButtonField with no border in Blackberry...
any help will be appreciated
bingo, just add the applyTheme() method
class BitmapButtonField extends ButtonField {
protected void applyTheme()
{
}
}
Arhimed & Rafael, thanks for you help!
Use this tutorial to create your own custom field.
Control the appearance of your field in paint() method.
Yes, this is possible by extending Field. You just need to create 2 images (one for a focused state and one for an unfocused state). Just don't draw the border on those images.
A sample implementation can be found here.
As Arhimed said, you should extend Field. This will give you the maximum amount of customization over how the button looks.
Here's an example of a customizable button I've created: https://github.com/HeshamMegid/BlackBerry-Custom-Controls
You could use it as it is or modify the code further to suit your needs.
I have developed a application with considering touch screen device for BlackBerry.
But when I am trying to use it in Non touch screen device all the lable also shows the focus.
Basically what I want that LabelField should not show any focus.
I have set NonFocusable Property for it but still it is not working.
Please help me out.
Thanks in advance...
You dont want the LabelField to have focus when you select it on touchscreen ?
Extend LabelField and override onFocus like so -
protected void onFocus(int direction) {
}
Also try overriding the LabelField's isFocusable() to always return false. It's possible that the GFM is just calling setFocus() on the next field without checking whether or not it can actually accept focus. If this is the case you may have to override the GFM's nextFocus() method and correct the logic.
Can anybody help me on this?
I tried to override onFocus(), onUnfocus() and paint() methods of ListField.
Please do a simple web search before post to stackoverflow.
Please go through the following links.
Create a Custom Listfield - Change Highlight Color when Scrolling by John Banks
Blackberry Tip: Change the default focus highlight color of ListField by Yincan Sheng