-
Bug
-
Resolution: Fixed
-
P3
-
fx2.1
-
2.1.0b13.
run attached sample:
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SplitMenuButton;
import javafx.stage.Stage;
public class SplitMenuButtonBug extends Application {
SplitMenuButton testSplitMenuButton;
@Override
public void start(Stage stage) {
ObservableList<MenuItem> testMenuItems = javafx.collections.FXCollections.<MenuItem>observableArrayList();
for (int indx = 1; indx <= 5; indx++) {
MenuItem mi = new MenuItem();
mi.setText("Test MenuItem -" + indx);
mi.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
System.out.println(e.getTarget());
}
});
testMenuItems.add(mi);
}
testSplitMenuButton = new SplitMenuButton();
testSplitMenuButton.getItems().clear();
testSplitMenuButton.getItems().addAll(testMenuItems);
testSplitMenuButton.setText("Test Menu");
testSplitMenuButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) { //Is not called.
System.out.println("catch");
System.out.println(t);
}
});
Scene scene = new Scene(new Group(testSplitMenuButton), 300, 300);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I expect, that pressing on split menu button, I see "catch" at least.
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SplitMenuButton;
import javafx.stage.Stage;
public class SplitMenuButtonBug extends Application {
SplitMenuButton testSplitMenuButton;
@Override
public void start(Stage stage) {
ObservableList<MenuItem> testMenuItems = javafx.collections.FXCollections.<MenuItem>observableArrayList();
for (int indx = 1; indx <= 5; indx++) {
MenuItem mi = new MenuItem();
mi.setText("Test MenuItem -" + indx);
mi.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
System.out.println(e.getTarget());
}
});
testMenuItems.add(mi);
}
testSplitMenuButton = new SplitMenuButton();
testSplitMenuButton.getItems().clear();
testSplitMenuButton.getItems().addAll(testMenuItems);
testSplitMenuButton.setText("Test Menu");
testSplitMenuButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) { //Is not called.
System.out.println("catch");
System.out.println(t);
}
});
Scene scene = new Scene(new Group(testSplitMenuButton), 300, 300);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I expect, that pressing on split menu button, I see "catch" at least.