So still kind of figuring out JavaFX, I was able to disable entering text in the textbox but I am not sure how to prevent the context menu from coming up when right clicked. Is anybody aware of how to prevent the default context menu from popping up when right clicked? `
//CombatFeedback is scrollable textbox to update user on what's happening.
TextArea CombatFeedback= new TextArea("Text.");
CombatFeedback.setPrefColumnCount(20);
CombatFeedback.setPrefRowCount(5);
CombatFeedback.setWrapText(true);
CombatFeedback.setStyle("-fx-font: 20 arial");
CombatFeedback.setEditable(false);
ScrollPane scrollerCombat = new ScrollPane(CombatFeedback);`
You can consume the event that signifies a request has been made for a context menu:
CombatFeedback.addEventFilter(ContextMenuEvent.CONTEXT_MENU_REQUESTED, Event::consume);
Related
I have to navigate between my components and I use a custom button like this:
button.addClickListener(click -> {
UI.getCurrent().navigate(ClassToNavigate.class);
});
The url does refresh in the search bar but it only shows a black page, I've to hit F5 to see the component in my parent layout.
My only fix is to add:
UI.getCurrent().getPage().reload();
...which reloads the page after navigating to the URL, and that breaks the UX in my opinion, however... when using a BeforeEnterEvent on a class and using the method:
forwardTo(ClassToNavigate.class);
redirects perfectly... although I can't have BeforeEnterEvent for every menu button I have, I can't see why forwardTo() works perfectly and navigate() doesn't.
Is there a way to navigate without having to reload the page? And without using RouterLink which I can't because I'm already using a custom component.
Thanks in advance!
Im using codename one 3.5.8 and need to add a checkbox to a multibutton(as the example https://www.codenameone.com/javadoc/com/codename1/components/MultiButton.html) but when adding it to my code ,it seems as though it is being ignored, the checkbox is not adde to my multibutton, this behavior happens on the emulator and also on my test device(android 6.0). is there anything that needs to be apllied additional to setCheckBox(true)
img2:
img3:
In case somebody is having this same behavior, the problem is because in some themes, the checkbox images make the checkbox invisible,the solution is to delete(or replace) the checkbox related images in the constant tab(on theme editor) like explained here:
CodenameOne - change color of checkbox in theme
The MultiButton itself should become a checkbox and would be rendered based on API conventions. You might need a revalidate() if the button is already showing in the UI.
Form hi = new Form("Multibutton", BoxLayout.y());
MultiButton component = new MultiButton();
component.setTextLine1("Name");
component.setTextLine2("Numero de reservacion:");
component.setTextLine3("Fecha de reservacion:");
component.setTextLine4("Estado:");
component.setCheckBox(true);
hi.addComponent(component);
hi.show();
I m a newbie in Vaadin and I am using a TabSheet where I attach some tabs. I was wondering if I could get some more functionality from their captions.
For instance, when a tab is selected and the user clicks its caption then a dropdown menu can appear.
I have already experimented with the existing listeners of TabSheet and I concluded that I have to make a custom listener. The thing is that I cannot find a way to fire the event when I click on the selected tab caption...
You could use SelectedTabChangeListener on a TabSheet. It would fire the event when the caption is clicked, and you could reselect your current tab, etc.. It would be cumbersome.
Why not use the MenuBar? Isn't it exactly what you want? https://demo.vaadin.com/valo-theme/#!menubars
I had the same problem (Vaadin 7.4), what you can do is you can surround the tab caption with a <div onclick="...">captionText</div> and add a JavaScript callback function:
final TabSheet sheet = new TabSheet();
sheet.setTabCaptionsAsHtml(true); // don't forget this!
// This is the callback
JavaScript.getCurrent().addFunction("clickedTab", new JavaScriptFunction() {
#Override
public void call(JsonArray arguments) {
LOGGER.info(arguments.getString(0)); // this is 'some identifier'
}
});
final TabSheet.Tab tab = sheet.addTab(component, "<div onclick=\"clickedTab('some identifier');\">captionText/div>");
I've tried using the new FileDownloader in Vaadin7. Unfortunately, it needs an AbstractComponent for the "extend" component (where it listens for the clicks)
Is there a way to use it with combobox items? As they are not AbstractComponents and thus do not fit with the "extend" method.
The Vaadin forums have discussed this a lot, and there is no scheme now using FileDownloader or the similarly functioning BrowserWindowOpener. They all only work on AbstractComponents, and thus don't work on Action handlers for Table and Tree, or row click handlers on Table, or MenuItem in Menu, etc. The same applies to selected elements in their various select boxes.
You have to revert to the popup window style (so browsers will need to allow popups for it to work) using a regular click/valuechange listener, creating a Resource and passing it to the deprecated, but still working, Page.getCurrent().open(Resource...) method.
Here is my work-around. It works like a charm for me. Hope it will help you.
This example is for the MenuItem, but you can modify for ComboBox.
Create a button and hide it by Css (NOT by code: button.setInvisible(false))
final Button downloadInvisibleButton = new Button();
downloadInvisibleButton.setId("DownloadButtonId");
downloadInvisibleButton.addStyleName("InvisibleButton");
In your theme, add this rule to hide the downloadInvisibleButton:
.InvisibleButton {
display: none;
}
When the user clicks on menuItem: extend the fileDownloader to the downloadInvisibleButton, then simulate the click on the downloadInvisibleButton by JavaScript.
menuBar.addItem("Download", new MenuBar.Command() {
#Override
public void menuSelected(MenuBar.MenuItem selectedItem) {
FileDownloader fileDownloader = new FileDownloader(...);
fileDownloader.extend(downloadInvisibleButton);
//Simulate the click on downloadInvisibleButton by JavaScript
Page.getCurrent().getJavaScript()
.execute("document.getElementById('DownloadButtonId').click();");
}
});
I have a button which opens a pop-up window and an Ajax update panel. Inside that window I have another button.
What code do I have to run if I want that update panel to be refreshed, when I press the button from the parent page, without refreshing the whole page?
I sow this code on a web which refreshes the page:
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
I am such a good friend with Java.
You need to utilize window.opener object.
window.opener.document.getElementById('Container').onclick();
I'd suggest using jQuery to ensure cross-browser compatibility. And also adding some null-checks of course.
Use Jquery :
If the DIV ID remains static :
$("#Container").click(function() {
// REFRESH CONTAINER HERE
});
If the Div ID is dynamic then make use of class instead of ID:
$(".Container").click(function() {
// REFRESH CONTAINER HERE
});