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
Related
I created basic vertical layout that work as side menu and now I want to place some buttons in it. Few of them gonna work as common side menu buttons, they just change page content so I want to mark that they are clicked in some way, how can I achive that? Or maybe there is better way?
As stated in the 5th version of Vaadin7 manual, you can attach an event listener to the Button.
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
// show the button has been clicked with a CSS class:
button.addStyleName("v-button-clicked");
}
});
Don’t forget to define the v-button-clicked class. Of course you’re free to add the class of your liking through the .addStyleName() method.
I need focusable horizontal field manager,for this i found some code in forums.
hfm[i]=new HorizontalFieldManager(HorizontalFieldManager.FOCUSABLE)
{
protected void onFocus(int direction)
{
Background bg = BackgroundFactory.createLinearGradientBackground(0x00E2E2E2,0x00E2E2E2,0x00E2E2E2,0x00E2E2E2);
setBackground(bg);
}
protected void onUnfocus()
{
Background bg = BackgroundFactory.createLinearGradientBackground(0x00FFFFFF,0x00FFFFFF,0x00FFFFFF,0x00FFFFFF);
setBackground(bg);
}
};
rtf[i]=new ExtendedLabel(list[i]);
hfm[i].add(rtf[i]);
add(hfm[i]);
But the it is not focusable,if it
You should also add this method to your new HorizontalFieldManager
public boolean isFocusable(){
return true;
}
Remember though when you set a manager to be focusable in this way it must have a field within it that is focusable or else you will get a null exception when the screen tries to give your managae focus.
This is a known problem that happens to everyone at least one time.
I started a topic in BB support forum:
Scroll happening but Vertical Field Manager Not Moving
And the answer given was the blackberry support forum article:
My scrollable manager is not scrolling
That is not a real answer but is the only workaround that's available for the moment
Another posible solution to this is:
A friend gave me the solution... you can put your manager into an
horizontal manager and then you can just add an nullfield with a
focusable behaviour, This will do the trick
You can try that.
You give focus to this.
rtf[i]=new ExtendedLabel(list[i]);
as....
rtf[i]=new ExtendedLabel(list[i],Field.Focusable);
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.
I am developing an app which supposed to work on devices that have OS 4.5 or later. In my application I need to know when the virtual keyboard is visible or invisible. Because if virtual keyboard is visible, the text area which the user is supposed to type in is behind the keyboard. If I could determine the moment of virtual keyboards state changed, I could refresh the screen and move the text area upper location.
Is there a way to do that?
Edit: the next button is at the status panel. The edit field is at the custom horizontal field manager.
When I touch the edit field, the virtual keyboard opens and the contents of the edit field is lost.
There is no way to do that with the same code. You need to divide your code in two. One of them handles 4.5 - 4.7. The other handles 4.7 and later.
You can add a keyboard listener to 4.7 (and later) code that should check whether the screen changes in a continuous thread. It is not good, but it can work.
You have two choices. The first choice is better:
Figure out an invariant that works with the keyboard visible or hidden. The screen layout method is invoked when the visibility state of the keyboard changes, and the vertical size is reduced for a visible keyboard. If your invariants take advantage of that then you can just implement the logic in the screen layout method.
In this case, I would suggest a layout method that always keeps the 'next' button at the bottom of the screen, and puts the username textbox in the center of the remaining space.
Use conditional compilation so you can write code that makes reference to the VirtualKeyboard class on OS 4.7+, and that code goes away in the older BlackBerry releases. 4 July: by conditional compilation, I mean use the BlackBerry preprocessor.
There is no event for this, but you can determine current state of virtual keyboard and set required state.
For example hide it
if(VirtualKeyboard.isSupported() == true){
VirtualKeyboard keyboard = getVirtualKeyboard();
if(keyboard != null)
keyboard.setVisibility(VirtualKeyboard.HIDE);
}
It is a quite challenging job. However, I believe there is no direct API or way to determine the virtual Keyboard state. The only way is to override the setLayout() method and determine if the screen width and height has been changed. And also you need to check the GUI layouts of your screen.
Set the VERTICAL_SCROLL style for the Manager which holds the EditField, or you can use a Screen with VERTICAL_SCROLL style. Doing this, the EditField automatically scrolls when the keyboard is displayed.
Use following class, maybe this is helpful for you:
class FocusableManager extends MainScreen implements FocusChangeListener
{
private BasicEditField b;
public FocusableManager()
{
VerticalFieldManager vfm=new VerticalFieldManager(VERTICAL_SCROLL);
vfm.add(new ButtonField("first"));
b=new BasicEditField();
b.setFocusListener(this);
vfm.add(b);
vfm.add(new ButtonField("second"));
vfm.setMargin(250,0,0,0);
add(vfm);
}
public void focusChanged(Field field, int eventType)
{
if(field==b)
{
if(eventType==1)//when edit field gain focus
{
VirtualKeyboard virtKbd;
virtKbd = getScreen().getVirtualKeyboard();
virtKbd.setVisibility(VirtualKeyboard.SHOW_FORCE);
}
else if(eventType==3)//when edit field lost focus
{
VirtualKeyboard virtKbd;
virtKbd = getScreen().getVirtualKeyboard();
virtKbd.setVisibility(VirtualKeyboard.HIDE_FORCE);
}
}
}
}
So i have 3 images in a vertical field manager and each image is clickable and proceeds to the correct url. all that works. the only problem at this time is that when i scroll (up or down), i don't know which image is currently focused. i don't know until the browser opens the corresponding url.
so is there any way to get a border or a highlight to appear under my images (or within the manager) so that i can definitely see which image is currently focused? so if you think of a list, your selections are highlighted as you scroll up and down. i want something similar to that with my application.
thank you for your help.
ac
using the setSpace(int,int) method on the bitmap field worked great. this allowed me to see a border around the element that had focus.
override inline the bitmapfield drawFocus method. Something like this
protected void drawFocus(Graphics graphics, boolean on){
graphics.setBackgroundColor(0x00204020);
graphics.drawRect(0, 0, getBitmapWidth(), getBitmapHeight());
}