开发者

XUL: Multiple reuse of an overlay in same file?

开发者 https://www.devze.com 2023-03-09 23:47 出处:网络
I\'m developing a Firefox extension. There is a 开发者_如何学JAVAmenu X which I need to show in both Tools menu and Context menu. Tools menu item and Context menu item are defined in same file but men

I'm developing a Firefox extension. There is a 开发者_如何学JAVAmenu X which I need to show in both Tools menu and Context menu. Tools menu item and Context menu item are defined in same file but menu X in another file.

As I'm reusing menu X by id only last use of it is effective. How can I reuse it multiple time in same file without redundancy?


It can be done using XBL.


I haven't found a good solution either. The approach is rather to define the menu in the overlay only once and then clone it in your "load" event handler. You can then insert the clone at the second location. You have to be careful because ID attributes have to stay unique - so if your menu uses ID attributes you will have to additionally rewrite them. Ugly, I know.


IDs are, per definitionem, unique. That means you can't share the menuitem but you can share the code that gets executed when the action is invoked. One way to achieve this is to use commands.

0

精彩评论

暂无评论...
验证码 换一张
取 消