Sorry, An Oversight from a cut and paste.

hi.setScrollableY(false);

With only Table table.setScrollableY(true); being scrollable,
swipe down to the bottom and tap the Row 2 or 3 or 4 cells and you will see 
the table scrolls to the top every time.

Regards.

On Wednesday, January 23, 2019 at 7:41:40 PM UTC-5, 
[email protected] wrote:
>
> If you are experiencing an issue please mention the full platform your 
> issue applies to:
> IDE: NetBeans/Eclipse/IDEA
> Desktop OS
> Simulator 
> Device PC, Android, IOS
>
> Sorry for the Table Population Hack,
>
> I am expecting to edit column 0 and when I click/Press on a row that 
> exists within the non scrolled region all is well.
> Scroll down then click/press a cell to edit (casted as TextField) and the 
> Table scrolls back to top.
> As soon as The Table scrolls back to top, the cell I pressed and was going 
> to edit, looses focus and of course would execute an actionEvent (Not Shown 
> Here)
>
> How do I prevent the scrolling back to top when I press a cell in this 
> case?
>
> Thanks In Advance!
>
>
>             Form hi = new Form("Table", new BorderLayout());
>             hi.setScrollableY(true);
>             Container header = new Container(new 
> BoxLayout(BoxLayout.Y_AXIS));
>             TableModel modelHeader = new DefaultTableModel(new 
> String[]{"Complaint", "Hours", "Dollars"}, new Object[][]{
>                  
>                  
>                 ,}) {
>                 public boolean isCellEditable(int row, int col) {
>                     return col != 0;
>                 }
>             };
>             Table table1 = new Table(modelHeader) {
>                 @Override
>                 protected TableLayout.Constraint 
> createCellConstraint(Object value, int row, int column) {
>                     TableLayout.Constraint con = 
> super.createCellConstraint(value, row, column);
>                     if (row == 1 && column == 1) {
>                         con.setHorizontalSpan(2);
>                     }
>                     con.setWidthPercentage(33);
>                     return con;
>                 }
>             };
>             header.addComponent(table1);
>             int RowNum = 1;
>             TableModel model = new DefaultTableModel(new String[]{"", "", 
> ""}, new Object[][]{
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row " + (RowNum++), "Row A", "Row X"},
>                 {"Row 2", "Row B can now stretch", null},
>                 {"Row 3", "Row C", "Row Z"},
>                 {"Row 4", "Row D", "Row K"},}) {
>                 public boolean isCellEditable(int row, int col) {
>                     if (col == 0) {
>                         return true;
>                     } else {
>                         return false;
>                     }
>                 }
>             };
>             Table table = new Table(model) {
>                 private int selectedRow = -1;
>                 @Override
>                 protected Component createCell(Object value, int row, int 
> column, boolean editable) {
>                     Component cell;
>                     if (row < 0) {
>                         cell = super.createCell(value, row, column, 
> editable);
>                     } else {
>                         if (column == 0) {
>                             cell = new TextField(value.toString());
>                             ((TextField) 
> cell).addPointerReleasedListener(e -> {
>                                 selectedRow = row;
>                                 setModel(getModel());
>                             });
>                         } else {
>                             cell = new Button(value.toString());
>                             cell.setUIID("TableCell");
>                             ((Button) cell).addPointerReleasedListener(e 
> -> {
>                                 selectedRow = row;
>                                 setModel(getModel());
>                             });
>                         }
>                     }
>                     if (selectedRow > -1 && selectedRow == row) {
>                         cell.getAllStyles().setBgColor(0xff0000);
>                         cell.getAllStyles().setBgTransparency(100);
>                     }
>                     return cell;
>                 }
>                 @Override
>                 protected TableLayout.Constraint 
> createCellConstraint(Object value, int row, int column) {
>                     TableLayout.Constraint con = 
> super.createCellConstraint(value, row, column);
>                     if (row == 1 && column == 1) {
>                         con.setHorizontalSpan(5);
>                     }
>                     con.setWidthPercentage(33);
>                     return con;
>                 }
>             };
>             hi.add(BorderLayout.NORTH, header);
>             table.setScrollableY(true);
>             hi.add(BorderLayout.CENTER, table);
>             hi.show();
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/83a11ab5-2a4d-4a61-9905-029f48a24281%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to