How to gray out an AnAction in the context/editor menu?
problem: the actions I "installed" in context and editor menus are never
grayed out.
They are AnAction subclasses, and I noticed their isAvailable() method
is only polled when I click on the entry, not when its containing menu
is expanded.
Alain
plugin.xml extract:
]]>
Please sign in to leave a comment.
Hi,
You can call setEnabled on presentation object in update method of AnAction.
Alain Ravet wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
I created a simple helper class for this:
public abstract class MyAction extends AnAction {
protected MyAction(String text, Icon icon) {
super(text, text, icon);
}
public void update(AnActionEvent event) {
event.getPresentation().setEnabled(isEnabled());
}
protected abstract boolean isEnabled();
}
Now you just have to implement the isEnabled() method.
Maxim Mossienko wrote:
>>
>> problem: the actions I "installed" in context and editor menus are
>> never grayed out.
>>
>> They are AnAction subclasses, and I noticed their isAvailable() method
>> is only polled when I click on the entry, not when its containing menu
>> is expanded.
>>
>> Alain
>>
>> plugin.xml extract:
>>
>>
>> > >> >> text="set miniWiki bugs file" >> description="set the miniWiki bugsfile" >> icon="/general/debug.png"> >> >> >> >> >> >> >> >> >> >> >> > anchor="last"/> >> >> >>]]>
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com