Friday, 15 June 2012

blackberry - Strange things happen when set margin to VerticalFieldManager -



blackberry - Strange things happen when set margin to VerticalFieldManager -

i'd generate verticalfieldmanager has none-zero margin, create verticalfieldmanager, , utilize vfm.setmargin(10, 10, 10, 10); after that, set fields(buttonfield, objectchoicefield) in it.

it seems simple, right? unusual thing happens. when focus lastly objectchoicefield , press space toggle selection of it, objectchoicefield disappeared.

how can be? here demo code, kindly find bug?

class="lang-java prettyprint-override">final class helloworldscreen extends mainscreen{ helloworldscreen() { // demo show unusual thing string [] arr = {"a","b"}; for(int = 0; < 10; i++){ verticalfieldmanager vfm = new verticalfieldmanager(); // field.use_all_width vfm.setmargin(10, 10, 10, 10); buttonfield btn = new buttonfield(string.valueof(i)); objectchoicefield ch = new objectchoicefield(string.valueof(i), arr); vfm.add(btn); vfm.add(ch); add(vfm); } } }

edit: screenshot of desired ui margins:

that strange.

for benefit of don't run code, what's happening when click on object selection fields, whole screen scrolling little bit vertically. after each vertical scroll, screen loses ability scroll way downwards bottom. after many such operations, much of lower part of screen no longer accessible.

i don't know why happening. (looks blackberry bug me)

what observed if take out phone call

class="lang-java prettyprint-override"> vfm.setmargin(10, 10, 10, 10);

the problem goes away.

may suggest workaround use

class="lang-java prettyprint-override"> vfm.setpadding(10, 10, 10, 10);

instead?

i know margin , padding not same thing. however, depending on total ui design (which cannot see), in case, setting 10 pixel padding may sufficient trying do.

update: based on screenshot of desired ui, able produce workaround. again, shouldn't much work, additional code worked me:

class="lang-java prettyprint-override">public class bugscreen extends mainscreen { private static final int bg_color = color.lightgray; private static final int fg_color = color.white; private static final int border_line_color = color.gray; private static final int pad = 10; public bugscreen() { super(mainscreen.vertical_scroll | mainscreen.vertical_scrollbar); getmainmanager().setbackground(backgroundfactory.createsolidbackground(bg_color)); // additional phone call ensures when scrolling bounces, area "behind" // normal visible area of bg_color setbackground(backgroundfactory.createsolidbackground(bg_color)); // found lean grayness padding on screen's left/right sides // note: seem drawing artifacts if seek utilize sides! getmainmanager().setpadding(0, pad, 0, pad); string [] arr = {"a","b"}; for(int = 0; < 10; i++){ verticalfieldmanager vfm = new verticalfieldmanager(field.use_all_width) { public int getpreferredwidth() { homecoming display.getwidth() - 2 * pad; } public void paint(graphics graphics) { int oldcolor = graphics.getcolor(); super.paint(graphics); graphics.setcolor(border_line_color); // draw (1-pixel wide) border size like. graphics.drawrect(0, 0, getpreferredwidth(), getheight()); graphics.setcolor(oldcolor); } }; vfm.setbackground(backgroundfactory.createsolidbackground(fg_color)); buttonfield btn = new buttonfield(string.valueof(i)); objectchoicefield ch = new objectchoicefield(string.valueof(i), arr); vfm.add(btn); vfm.add(ch); // add together separator field lean grayness margin between (vfm) fields add(new marginfield()); add(vfm); } // add together 1 lastly margin field @ bottom add(new marginfield()); } private class marginfield extends field { public marginfield() { super(field.use_all_width); } public int getpreferredheight() { homecoming pad; } protected void paint(graphics g) { int oldcolor = g.getcolor(); g.setcolor(bg_color); g.fillrect(0, 0, getwidth(), getpreferredheight()); g.setcolor(oldcolor); } protected void layout(int width, int height) { setextent(width, getpreferredheight()); } } }

blackberry

No comments:

Post a Comment