当光标移到SWT表格的右侧时,水平条不会移到所选列的右侧

当光标移到SWT表格的右侧时,水平条不会移到所选列的右侧,swt,horizontal-scrolling,Swt,Horizontal Scrolling,我已将现有的SWT表格转换为excel表格,但当光标移动到表格右侧(即当前视图中的表格外)时,水平条不会向右移动,但垂直移动很好 我在某处读到SWT工作台不可能水平移动 public void addTreeNavigationBehavior(final Tree treeComposite){ final TreeCursor cursor = new TreeCursor(treeComposite, SWT.NONE); final ScrolledCo

我已将现有的SWT表格转换为excel表格,但当光标移动到表格右侧(即当前视图中的表格外)时,水平条不会向右移动,但垂直移动很好

我在某处读到SWT工作台不可能水平移动

public void addTreeNavigationBehavior(final Tree treeComposite){
        final TreeCursor cursor = new TreeCursor(treeComposite, SWT.NONE);

        final ScrolledComposite scrolledComposite = new ScrolledComposite(treeComposite, SWT.NONE);

        final ControlEditor editor = new ControlEditor(cursor);
        editor.grabHorizontal = true;
        editor.grabVertical = true;
        cursor.addSelectionListener(new SelectionAdapter() {
            // when the TableEditor is over a cell, select the corresponding row in 
            // the table
            @Override
            public void widgetSelected(SelectionEvent e) {
//              cursor.scroll(0, 0, 0, 0, 0, 0, true);
                //need to attach the a method to this say is selectable 
                scrolledComposite.setExpandHorizontal(true);
                treeComposite.setSelection(cursor.getRow());
//              treeComposite.getHorizontalBar().setSelection(cursor.getColumn());
//              cursor.getHorizontalBar().setSelection(cursor.getColumn());

            }
            // when the user hits "ENTER" in the TableCursor, pop up a text editor so that 
            // they can change the text of the cell
            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                final Text text = new Text(cursor, SWT.NONE);
                TreeItem row = cursor.getRow();
                int column = cursor.getColumn();
                text.setText(row.getText(column));
                text.addKeyListener(new KeyAdapter() {
                    @Override
                    public void keyPressed(KeyEvent e) {
                        // close the text editor and copy the data over 
                        // when the user hits "ENTER"
                        if (e.character == SWT.CR) {
                            TreeItem row = cursor.getRow();
                            int column = cursor.getColumn();
                            row.setText(column, text.getText());
                            text.dispose();
                        }
                        // close the text editor when the user hits "ESC"
                        if (e.character == SWT.ESC) {
                            text.dispose();
                        }
                    }
                });
                // close the text editor when the user tabs away
                text.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {
                    @Override
                    public void focusLost(FocusEvent e) {
                        text.dispose();
                    }
                });
                editor.setEditor(text);
                text.setFocus();
            }
        });
        // Hide the TableCursor when the user hits the "CTRL" or "SHIFT" key.
        // This allows the user to select multiple items in the table.
        cursor.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                if (e.keyCode == SWT.CTRL
                    || e.keyCode == SWT.SHIFT
                    || (e.stateMask & SWT.CONTROL) != 0
                    || (e.stateMask & SWT.SHIFT) != 0) {
                    cursor.setVisible(false);
                }
            }
        });
        // When the user double clicks in the TableCursor, pop up a text editor so that 
        // they can change the text of the cell.
        cursor.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                final Text text = new Text(cursor, SWT.NONE);
                TreeItem row = cursor.getRow();
                int column = cursor.getColumn();
                text.setText(row.getText(column));
                text.addKeyListener(new KeyAdapter() {
                    @Override
                    public void keyPressed(KeyEvent e) {
                        // close the text editor and copy the data over 
                        // when the user hits "ENTER"
                        if (e.character == SWT.CR) {
                            TreeItem row = cursor.getRow();
                            int column = cursor.getColumn();
                            row.setText(column, text.getText());
                            text.dispose();
                        }
                        // close the text editor when the user hits "ESC"
                        if (e.character == SWT.ESC) {
                            text.dispose();
                        }
                    }
                });
                // close the text editor when the user clicks away
                text.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {
                    @Override
                    public void focusLost(FocusEvent e) {
                        text.dispose();
                    }
                });
                editor.setEditor(text);
                text.setFocus();
            }
        });

        // Show the TableCursor when the user releases the "SHIFT" or "CTRL" key.
        // This signals the end of the multiple selection task.
        treeComposite.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0) return;
                if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) != 0) return;
                if (e.keyCode != SWT.CONTROL && (e.stateMask & SWT.CONTROL) != 0) return;
                if (e.keyCode != SWT.SHIFT && (e.stateMask & SWT.SHIFT) != 0) return;

                TreeItem[] selection = treeComposite.getSelection();
                TreeItem row = (selection.length == 0) ? treeComposite.getTopItem() : selection[0];
                treeComposite.showItem(row);
                cursor.setSelection(row, cursor.getColumn());
                cursor.setVisible(true);
                cursor.setFocus();
            }
        });

    }

添加快照和代码。我没有为水平或垂直移动明确编码任何东西。我只想知道为什么垂直方向有效而水平方向无效。@user1719010但我们需要查看您的代码,以便能够重现您的问题并提出解决方案。