Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,8 @@ void onPageTraversal(Event event) {
if (e.doit && !isDisposed()) {
showList(chevronRect);
}
} else {
index = visible [(current + offset + idx) % idx];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.swt.snippets;

/*
* CTabFolder example: circular keyboard page traversal.
*
* Give the CTabFolder focus and press Ctrl+PageDown / Ctrl+PageUp to move
* between tabs. With setMRUVisible(true) and no chevron shown (all tabs fit),
* navigating past the last tab now wraps around to the first tab, and
* navigating before the first tab wraps around to the last tab.
*
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
*/
import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Snippet395 {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
shell.setText("Snippet 395");

Label label = new Label(shell, SWT.WRAP);
label.setText("Give the CTabFolder focus and press Ctrl+PageDown / Ctrl+PageUp.\n"
+ "Navigation now wraps around: last tab + PageDown -> first tab,\n"
+ "first tab + PageUp -> last tab.");
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

CTabFolder folder = new CTabFolder(shell, SWT.BORDER);
folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// Enable most-recently-used tab ordering; all tabs below fit without a
// chevron, which is the case this fix addresses.
folder.setMRUVisible(true);

for (int i = 0; i < 4; i++) {
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText("Tab " + i);
Text text = new Text(folder, SWT.MULTI);
text.setText("Content for Tab " + i);
item.setControl(text);
}
folder.setSelection(0);

shell.setSize(400, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Loading