Cancel scrolling in Layout Manager


I can't find solution for the following problem. I have custom list field, which overlaps the boundaries of its layout manager. List field consumes navigation events from manager to highlight currently selected row with special color. Layout manager is configured to support scrolling. When I scroll trackwheel down, layout manager invokes scrolling and then passes navigation event to its child, the list field. It results in inproper scrolling, because manager scrolls the whole list down to its bottom hiding list rows on the top including the selected row.

What I want is to ignore scrolling while currently selected list row is still visible and employ it otherwise.

I'm using JDE 4.2.1


Let's say we have ListField implementation:

class LabelListField extends ListField implements ListFieldCallback { private Vector mValues; public LabelListField(Vector values) { super(0); setRowHeight(getFont().getHeight() + 10); setCallback(this); mValues = values; setSize(mValues.size()); } public void drawListRow(ListField listField, Graphics g, int index, int y, int width) { g.drawText((String) mValues.elementAt(index), 0, y); } public Object get(ListField list, int index) { return mValues.elementAt(index); } public int indexOfList(ListField list, String prefix, int start) { for (int x = start; x < mValues.size(); ++x) { String value = (String) mValues.elementAt(x); if (value.startsWith(prefix)) { return x; } } return -1; } public int getPreferredWidth(ListField list) { return Display.getWidth(); } }

If we want to align this list within upper and lower fields this way: <a href="http://img6.imageshack.us/img6/7025/8800j.png" rel="nofollow">ListField with scroll http://img6.imageshack.us/img6/7025/8800j.png</a><br /> we can limit it's height using custom manager:

class ListManager extends HorizontalFieldManager { ListField mListField; public ListManager(ListField listField) { super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR); mListField = listField; add(mListField); } public int getPreferredHeight() { int result = Display.getHeight(); Manager manager = getManager(); if (null != manager) { for (int i = 0, count = manager.getFieldCount(); i < count; i++) { if (manager.getField(i) != this) result -= manager.getField(i).getPreferredHeight(); } } // size down to fit max rows without splitting result = result - result % mListField.getRowHeight(); return result; } protected void sublayout(int maxWidth, int maxHeight) { super.sublayout(maxWidth, maxHeight); setExtent(maxWidth, getPreferredHeight()); } }

Now we can use it:

class Scr extends FullScreen implements FieldChangeListener { LabelField mHeader; ListManager mHFMList; HorizontalFieldManager mHFMButton; LabelListField mListField; ButtonField mButton; public Scr() { super(DEFAULT_MENU | DEFAULT_CLOSE); mHeader = new LabelField("List Field", FIELD_HCENTER); add(mHeader); Vector values = new Vector(); values.addElement("first"); values.addElement("second"); values.addElement("third"); values.addElement("fourth"); values.addElement("fifth"); values.addElement("sixth"); values.addElement("seventh"); values.addElement("eight"); mListField = new LabelListField(values); mHFMList = new ListManager(mListField); add(mHFMList); mHFMButton = new HorizontalFieldManager(FIELD_HCENTER); add(mHFMButton); mButton = new ButtonField("Exit", ButtonField.CONSUME_CLICK); mButton.setChangeListener(this); mHFMButton.add(mButton); } public void fieldChanged(Field field, int context) { if (mButton == field) close(); } }

Tested on eJDE 8800


all here's the solution that helped me. By overriding moveFocus in such specific way I managed to modify default behavior of scrolling in layout manager - it skips first items of list field allowing them to stay on top.

public int moveFocus(int amount, int status, int time) { invalidate(getSelectedIndex()); int unused = super.moveFocus(amount, status, time); return Math.abs(unused) + 1; }


  • Vaadin grid setBodyRowHeight doesn't exist in latest 8.1.4 API
  • Adding a ContactsContract.CommonDataKinds.Event to Android contacts, does not show up
  • How to send data from Raspberry pi to Google Cloud IoT Core, using Android Studio?
  • get ERROR_CAMERA_ALREADY_IN_USE when usb debugging on my Nexus 5 with libstreaming
  • Swing - Change menu bar and menu items font size in runtime
  • Get font height/weight from TextRenderInfo how?
  • UIPopoverController for iPhone
  • UpdateException when using SQL Server Compact with Entity Framework
  • SyntaxError: Unexpected token ' in JSON at position 1
  • Android: Accessing and querying properly using Raw Contact Id
  • Wordpress and Google Analytics Events
  • Cassandra eats memory
  • Get process output without blocking
  • Need to display iframe when link is clicked from menu
  • Getting p-values from leave-one-out in R
  • Vim syntax highlighting
  • Java - Change the color of some squares created with Graphics2D
  • Centering a texture LibGDX
  • In Ember.js, what's the difference between store save and store commit?
  • Why can't pass only 1 coulmn to glmnet when it is possible in glm function in R?
  • Matlab Generating a Matrix
  • How to reduce image size into 1MB
  • Error: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
  • runtime-check whether an instance (Base*) override a parent function (Base::f())
  • Is there a package like bigmemory in R that can deal with large list objects?
  • how to avoid repetitive constructor in children
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • Initializer list vs. initialization method
  • Deleting and Updating values from a cusrsor adapter
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Convert array of 8 bytes to signed long in C++
  • JTable with a ScrollPane misbehaving
  • Understanding cpu registers
  • unknown Exception android
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?