The custom task pane has a down arrow button at the top right corner which if you click on it a contextual menu appears showing two options:
Resize
Close
I would like to handle the event when user resize the height of the custom task pane and gather the height set by the user. Is that possible? if so, how? what event do I need to handle?
Your task pane is a user control where you could override methods in the following way:
protected override void OnSizeChanged(EventArgs e)
{
// this.Size
base.OnSizeChanged(e);
}
Don't forget that you could also override the windows procedure which processes Windows messages - WndProc, where you could detect such actions like closing (see WM_CLOSE).
Related
I have and VSTO Outlook Add-in which has a custom task pane at the top. Now I am trying to detect if there is a way or some trick to detect when the custom task pane is being resized (its height). Height resize can be done through the menu or clicking on the custom task pane splitter. So how can I detect that the user is being resizing the custom task pane height? is there some way?
You can override the OnResize method in any user control, for example, the following code can be used for the Outlook form region instance or custom task pane:
protected override void OnResize(EventArgs e)
{
// add your code here
base.OnResize(e);
}
Or just handle the Resize event of the UserControl class:
private void UserControl1_Resize(object sender, EventArgs e)
{
// add your code here
}
I want change behavior of standard close button of window. When user clicked on it then minimize to tray, not close window. How can I do this?
P.S Here is a small video example of this behavior on Slack application. I want do same.
Override the applicationShouldTerminateAfterLastWindowClosed method in appdelegate like:
public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender)
{
return false;
}
I have two windows: A main window and an inspector panel. Both have sliders and draggable items.
You have to click twice every time you work in the other window. First click activates the window. Second click allows a drag to start.
Is it possible to have a click in a window automatically activate it AND allow the event to pass through to the controls so you don't need to do it twice all the time when switching between an inspector panel and main window?
The first thing to try is to set the panel's becomesKeyOnlyIfNeeded property to true. That way, you main window will remain key even if the user clicks and drags on controls within the panel.
Otherwise, you have to handle this in each different view class. A view should override -acceptsFirstMouse: to return true if it wants to handle the same mouse event that activates the window. For custom view classes, this is straightforward. If you're using standard controls and they don't already implement -acceptsFirstMouse: to return true, you'll need to subclass them and use those subclasses instead.
I have a GUI with several menus.
The current menu is the child of a StackPane which in turn is a child of a RootLayout (GridPane) and there is only one menu active at a time which means that the StackPane has only one child at a time.
The menu switches by replacing all children in the StackPane with the new page.
(theStackpane.getChildren().setAll(newMenu);)
The active menu may have a button that changes the menu, so a click on the button replaces all children in the StackPane (the one with the button you just clicked as well).
The problem is, when there is a button that changes the menu and there is a button at the same location in the new menu, both buttons get clicked, although you just clicked the first button (which changes the menu).
The structure is like this:
RootLayout
.theStackPane
..activeMenu
...oneButton
A click on oneButton (that changes the menu) leads to:
RootLayout
.theStackPane
..newMenu
...twoButton
The StackPane stays the same, just all children of theStackPane get exchanged by new ones.
Now if oneButton is at the same location of twoButton, oneButton gets activated, changes the menu by replacing all children, newMenu is shown, twoButton gets activated and does whatever it does - stop.
Although I'd like to have it like this:
If oneButton is at the same location of twoButton, oneButton gets activated, changes the menu by replacing all children, newMenu is shown - stop.
How do I prevent the current behaviour?
buttonOne & buttonOnNewPage are inside the same stackPane, right? Then that happens because in the event capturing phase the stackPane propagates the event to both buttons so when the handler tries to consume it, it has already been propagated.
So, instead of using a handler in buttonOne lets try using a filter, and inside it consuming the event. Try something like this:
EventHandler filter = new EventHandler(<TouchEvent>() {
public void handle(TouchEvent event) {
theStackPane.getChildren().setAll(newPage);
event.consume();
}
}
buttonOne.addEventFilter(TouchEvent.TOUCH_PRESSED, filter);
I finally got to a solution:
I got it to work as expected when I switched setOnTouchPressed to setOnAction.
I don't event need to consume the ActionEvent when I touch oneButton.
So instead of
oneButton.setOnTouchPressed(e -> {
theStackPane.setAll(newPage);
});
I am now using
oneButton.setOnAction(e -> {
theStackPane.setAll(newPage);
});
I have a little popup window used for selecting images sorted by groups, and I would like to add a selection box around whatever image is being hovered over. I am trying to this by overriding the mouseMoved event for the window but it seems that a window that has a border-less style mask receives no mouseMoved events even if you have set setAcceptsMouseMoved events to YES. Is there anyway to make a borderless window receive this events?
You need to allow the window to become the key window. By default, borderless windows cannot become key. Subclass NSWindow and override -canBecomeKeyWindow:
- (BOOL)canBecomeKeyWindow
{
return YES;
}
Aternatively, you can use an NSTrackingArea to do your mouse tracking, which may be easier/better anyway.