How do i set this kind of behaviour?, currently the hover(mouseEntered) is fine, it shows up the DateChooser whenever the cursor goes inside the DatePicker, but whenever the mouse exits from the DatePicker it hides the DateChooser. I can´t find such method that gives access to the DateChooser itself.
It´s only fixed to not close the DateChooser when the cursor goes under the DatePicker, but the DateChooser should be close whenever the mouse goes out from it.
datePicker.setOnMouseEntered((event)->{datePicker.requestFocus();datePicker.show();});
datePicker.setOnMouseExited((event)->{if(event.getY()<23)datePicker.hide();});
Accessing the skin allows you to access the content of the popup which allows you access to the popup's Scene, which allows you to add a onMouseExited handler to that scene for hiding the popup:
EventHandler<MouseEvent> exitHandler = e -> datePicker.hide();
datePicker.setOnShown(evt -> {
DatePickerSkin skin = (DatePickerSkin) datePicker.getSkin();
Scene sc = skin.getPopupContent().getScene();
sc.setOnMouseExited(exitHandler);
});
Not a nice solution, since it requires accessing the skin located in the com.sun packages, but it is a solution.
Related
I am migrating an application from Flex/Flash to Flex/AIR 32.
Many years ago I began using the flextenibles SpellCheck module. It creates a custom component for textArea which will underline misspelled words then display misspelled word in a context menu.
I have successfully migrated it, however the only way to get the custom context menu to popup is by very carefully right mouse clicking the squiggly line under the text, not the text itself. When I right click the text it displays a default context menu. It actually never gets to the function to build custom context menu. I have place the following code in a variety of places in the custom class which extends mx.controls.textArea;
private function creationCompleteHandler(event:Event):void
{
this.contextMenu = new ContextMenu;
this.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT,showMenu);
}
Including in the constructor and its original location createChildren with the same behavior.
In the Flex/flash version right clicking the text would bring up the custom context menu.
Edit:
As I do more debugging, I find "this.textField" from within the component is firing MouseEvent.CONTEXT_MENU, and it is never getting to the "this.contextMenu" event.
Well I found a work around.
I used the following to create the event listener;
this.textField.addEventListener(MouseEvent.CONTEXT_MENU,showMenu);
Then I changed the handler to use the event data from a mouseEvent instead of contextMenuEvent, this seems to work.
I have a Qt form, where I have a button and menu. For various reasons I can disable certain elements, e.g button or some actions in the menu.
Is there a way I could show a tooltip or when the mouse is hovered over the disabled button or menu item with an explanation as to why it is disabled?
I am using Qt 4.8.
Thanks!
You can set the tooltip dynamically based on the state of the QWidget or by simply toggling both at the same time. Upon disabling/enabling the widget from somewhere just call QWidget::setToolTip(...) with the QString you want the tooltip to display when hovering with the mouse over the given widget. For example if you have a public slot called toggleButton(bool toggleFlag) which toggles the enable-setting of a button you can do:
void MyWidget::toggleButton(bool toggleFlag) {
this->ui->myButton->setEnabled(toggleFlag);
this->ui->myButton->setToolTip(toggleFlag ? QString("Enabled wohoo!") : QString("Disabled because I like it"));
}
You can of course do also change the tooltip by calling QWidget::isEnabled() and act upon its return value. Since you haven't given any code I can only assume how you toggle your button(s) so that's all I can give you for now.
UPDATE: It was pointed in the comments that tooltips don't work with disabled widgets due not receiving mouse events. Both statements are not true (note that I have used the same tooltip message since due to lack of minimal working example I didn't want to write a whole new project from scratch and used an existing one of mine instead):
Hovering a disabled button triggers the tooltip
Hovering an enabled button triggers the tooltip
Is there any way to create a custom PopUp in JavaFX? I can't use tooltip, since I would like it to appear on double click, also I would like a different style than the standard tooltip.
My demands for the popup are:
1. If the user double click, show the popup
2. if the user clicks outside the popup, hide it
See this guide on all the different types of popups.
Use Popup.
Popup popup = new Popup();
// add content (you can add as many nodes as you want)
popup.getContent().add(new Label("Hello Popup!"));
// show (move this to the double-click listener)
popup.show(primaryStage);
// hide (move this to the click listener)
popup.hide();
I was trying to generate a resizable and drag/droppable ajax control toolkit accordion control programmatically, but am running into some problems.
First, can it be done?
Second, my approach is not exactly working.
I have a button that, OnClick, is supposed to create the accordion. So I create the accordion. Add an accordion pane to it. Add a combo button to the accordion pane. Then add the entire accordion to the Ajax Panel. My event handler follows.
protected void btnTest_Clicked(object sender, EventArgs e)
{
//Generate the accordion
AjaxControlToolkit.Accordion acc = new AjaxControlToolkit.Accordion();
//Generate a single accordion pane
AjaxControlToolkit.AccordionPane itm = new AccordionPane();
//Create and add a control to the pane
AjaxControlToolkit.ComboBoxButton cbbtn = new ComboBoxButton();
itm.Controls.Add(cbbtn);
acc.Panes.Add(itm);
//Add resizable extender to the accordion. Only did resizable for now.
//One step at a time.
AjaxControlToolkit.ResizableControlExtender extResizeLocation = new AjaxControlToolkit.ResizableControlExtender();
extResizeLocation.TargetControlID = acc.ID;
extResizeLocation.Enabled = true;
//Add accordion to update panel and update.
UpdatePanel1.Controls.Add(acc);
UpdatePanel1.Update();
}
What I get when I press the test button is what appears to be a minimized button without text generated under the test button. I have no clue what to do.
Appreciate the help
Dynamically added controls are typically supposed to be added during init or preinit event of the page. That may be a complication, since you are doing it after load.
The key is to make sure the $register method on the client for the accordion is occurring. This is what initializes the client-side features of the AJAX component, and starts the lifecycle. I don't know if it happens for dynamically added controls...
You may want to look at the JQuery UI Accordian widget and use the draggable/droppable interactions.
You could use server side code to create an block and apply the jQuery interaction.
I'm trying to use the PopupManager class in a Flex3 AIR app to open different kinds of panels but I'm running into some problems with it. I'm using a method like the following with which all panels are opened ..
private function createPopUp(clazz:Class, modal:Boolean = false):IFlexDisplayObject
{
var p:IFlexDisplayObject = IFlexDisplayObject(PopUpManager.createPopUp(_windowParent, clazz, modal));
PopUpManager.centerPopUp(p);
return p;
}
_windowParent is a reference to the application's WindowedApplication root object. I'm running into two kinds of problems with this:
Not all popups appear modal, even if I set the modal parameter to true. This seems to happen if I open a popup panel from within another popup panel.
In some of the popup panels are ComboBoxes and the popdown menu of the comboboxes opens underneath of their parent panel (i.e. under the depth of the panel) so the menu of the combobox becomes partly or fully obstructed.
I've tried different parameters for the PopUpManager.createPopUp() childList parameter (e.g. PopUpManagerChildList.APPLICATION) but that did not change anything.
Hoping that anyone has some tips on these problems!
Nevermind! Figured out I some code that would change the depth of panels that was messing this up.