There's no problem in showing nested figures in GEF on mouse hover. On mouseHover(MouseEvent me), I add(IFigure), and on mouseExited(MouseEvent me) I remove the figure.
But as soon as I add a Button(Draw2d), or I add a figure which has a MouseListener() attached to it, now when I hover over the newly added figure(inside the parent), it disappears.
I figured the problem is that the first figure calls its mouseExited(MouseEvent me) method.
So, I did this in the parent figure's mouseExited(MouseEvent me):
Point exitLocation = me.getLocation();
if (containsPoint(exitLocation.x, exitLocation.y) == false) {
remove(childFigure);
}
I see on mouse exit, if it still is in the bounds of the parent figure, it doesn't remove the child figure.
But this works most of the time. Sometimes my mouse is out of the parent figure completely, yet the child figure isn't removed from the parent figure. I have no idea what is happening.
Is this a bug? Or is there a better way to do this?
I would suggest to try using a different strategy in hiding/showing figures:
On parent creation always add the child and mark it as not visible, child.setVisible(false)
Replace all add() and remove() invocation respectively with setVisible(false) and setVisible(true)
Related
I'm working on an MFC project (old technology, I know).
In my dialog-box class (derived from CDialog) I have:
CToolTipCtrl m_cToolTipCtrl;
CWnd m_cImageWindow;
In the class OnInitDialog function I do:
m_cToolTipCtrl.Create(this);
m_cImageWindow.CreateEx(...);
m_cToolTipCtrl.AddTool(this,_T("Parent"));
m_cToolTipCtrl.AddTool(&m_cImageWindow,_T("Child"));
In the class PreTranslateMessage function I do:
m_cToolTipCtrl.RelayEvent(pMsg);
When I run the project, the "Parent" tooltip is displayed whenever I hover within the parent window, but the "Child" tooltip is not displayed whenever I hover within the child window.
I have originally tried this without the "Parent" tooltip and it didn't work, so it is obviously not a matter of the "Parent" tooltip masking the "Child" tooltip.
I think that events are relayed only to the parent window, but I'm not really sure how to tackle this problem.
Putting a breakpoint in the PreTranslateMessage function is useless, since it stops eminently on every event that the application receives. How can I investigate this problem?
Found the answer:
Simply add the SS_NOTIFY flag to the child window style when creating it.
For example:
m_cImageWindow.CreateEx(0,WC_STATIC,NULL,WS_CHILD|SS_NOTIFY,{0,0,0,0},this,0);
I am trying to create a Today Widget in Swift with XCode. I started with the available example code of XCode, when you create a new Today Widget target. The content of my Today widget is loaded from an external source, and whenever a new item appears in the external source it is added to the widget on refresh (widgetPerformUpdateWithCompletionHandler).
The only thing that bugs me is that new items automatically slide in from the top, overlapping all previous items and finally reaching the final destination at the bottom of the list. How can I change this behavior to either slide in from the bottom or not at all and just appear without sliding. I think I know how I could do my own animation with ...view.animator()... but the original functionality is nowhere to be found in my code and I can't figure out how to disable it.
By now I'm pretty sure where it comes from. I assume the list items NSView is initiated with NSViewControllerTransitionOptions and the SlideDown option activated. So the animation comes from the views NSViewControllerPresentationAnimator. Unfortunately presentViewController is not called by myself. This probably is somewhere in the internals of NCWidgetListViewDelegate, which has no option to prevent or change the animation. So I guess, the only way how to "fix" this is to drop NCWidgetListViewDelegate completely and start from scratch. So the answer would be: It's not possible.
I need to fire a method when a figure is selected in GEF diagram.
addSelectionChangedListener works well when I select a figure, but if i click on the same figure again ("unselect") the listener doesn't fire.
How can i fix it?
final GraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
//Fired when figure is selected, but not when same figure is selected again
}
});
I don't think you can implement a toggling behaviour for a GEF figure through the selection mechanism. The selectionChanged event gets fired when the selection changes, so clicking twice on the same figure is not going to make it.
Maybe a different approach is needed taking into consideration that a figure is deselected when another figure gets selected and that you can retrieve the that element from the SelectionChangedEvent object passed in.
Also, you should only care about the user selecting a figure within the diagram and not a different element from any other workbench part.
Hey guys, I've just migrated my image selector from NSCollectionView to IKImageBrowserView. I've got almost everything set up the way I want it, except for the selection ring. I don't like the greyed out background that IKImageBrowserView defaults to, and I wanted to do a yellow stroke around the edge of my selected image to indicate it's selection (like in iPhoto). Is is possible to override the draw state of IKImageBrowserCell? I haven't been able to find any way to do it yet. It doesn't have the simple drawRect methods that I'm used to. Any help would be appreciated. I'm assuming I have to use CALayers?
I overrode - (CALayer *)layerForType:(NSString *)type and tried just as a test, setting the layer corner radius to 0, but it didn't seem to change anything. The method is being called because if I throw a breakpoint in it, it stops there. However, even if I return nil from that method, it still draws the images like usual.
Thanks!
That is the right method for customizing the IKImageBrowserCell.
Using CALayers and configuring different attributes, you can control many facets of how the images are presented.,
A layer of type = IKImageBrowserCellSelectionLayer is what you will want to change to have the display behave and present as you wish.
Here's a link to Apple's sample code project that will get you started
I have an NSCell subclass that I do all kinds of custom drawing in. The only time things seem to be entirely out of my control is when right clicking a cell to show the associated context menu. While showing it's context menu, the table (or cell - not sure which exactly is doing this) draws a focus rect. I would like to get rid of this, or at least find a way to draw my own version of it that better fits within my interface.
I have tried about 15 different methods that seem like they could give me control over this focus rect drawing itself (various first responder methods, various drawing methods, various highlight color methods, etc.), but I have yet to find something that changes anything about it.
Screenshot of the problem: http://twitpic.com/3zx2t
I am almost annoyed enough to class-dump AppKit and try to find whatever private method it's using to draw this annoying focus rect. Nothing else I do has any effect on it. Any help here would really save both my sanity and lots of future hair pulling.
Thanks so much!
Without completely overriding your table view's -drawRect: this is the only other way I know to get rid of the context menu highlight rect.
- (void)_drawContextMenuHighlightForIndexes:(NSIndexSet *)rowIndexes clipRect:(NSRect)rect {
return;
}
This is the method, used in Leopard at least, to draw the highlight around cells that will be activated upon by a context menu. It is unfortunately called directly by NSTableView's -drawRect: method and as far as I know there is no other way to signal your disinterest in having those highlights drawn.
Of course this is private API, it may stop working in Snow Leopard, or some other release. But at worst that means that somewhere along the way the context menu highlight may start up again in your programs on newer releases or some other functionality using this method may not work later. You have been warned.
On 10.5 and later, NSTableView allows you to bring up a contextual menu on any item in the table (that is, without having the side effect of changing the selection.)
It draws that 'focus rect' to indicate which item(s) are being acted on by the contextual menu.