Open imagejan opened 6 years ago
We don't have to use ActionListener
... we could have our own UI-agnostic interface, no? But perhaps run()
is already good enough. Why not simply have the JPopupMenu
appear in the action's run()
method directly? Do we need a second method in the action?
Alternately, if you want to have a UI-agnostic "sub-actions" mechanism, we could add that.
My idea was to display a popup menu with options at the position of the button when it is clicked, so I'd actually need to have access to the button, e.g. by actionEvent.getSource()
.
I realize that this might be too UI-centric after all.
Currently, we generate a default
ActionListener
for everySearchAction
in the details pane: https://github.com/scijava/scijava-search/blob/14315f805141d18c71c712225cc8fbfde090cfa6/src/main/java/org/scijava/ui/swing/search/SwingSearchBar.java#L514-L521Allowing for
SearchAction
s to provide their ownActionListener
would allow more flexibility, e.g. displaying a small popup menu (JPopupMenu
) with additional (sub-)choices that wouldn't justify the creation of an ownSearchAction
for them.This goes in the same direction as https://github.com/scijava/scijava-search/issues/4 to provide more flexibility to define search actions.
The problem with allowing with allowing
ActionListener
as a parameter would be that we introduce an awt dependency in a UI-agnosticSearchAction
, so this would have to be abstracted somehow...