Initial state of buttons wrong when located in app panel. #19

Closed
Gitoffthelawn opened this Issue Nov 5, 2014 · 3 comments

Projects

None yet

3 participants

@Gitoffthelawn

When the buttons are located in the app panel, the initial visible state of all the buttons is off (red), even if the functionality they represent is not off. For example, images button will be red even though images are not disabled.

@Quicksaver

This is because the "customizationchange" listener the add-on implements is not enough. For example, if you place QJ's buttons in any of the Puzzle Toolbars the same thing will happen (PS never mind the faulty/cropped icons in this case, I've already fixed it in the latest PZT beta).

In both cases, the toolbars/panel are created after the buttons whole initialization, and the "customizationchange" event isn't fired when the buttons are automatically placed there at this point to update their status.

Simple solution: instead of the customizationchange event listener, implement a listener with CustomizableUI like the following:

var CUIListener = {
  handler: function() {
    /* Our toolbar icons may have been added or removed to/from a toolbar or panel */
    thatoneguydotnet.QuickJava.updateIcons();
  },
  onWidgetAdded: function(aWidgetId) { this.handler(); },
  onWidgetRemoved: function(aWidgetId) { this.handler(); },
  onAreaNodeRegistered: function() { this.handler(); },
  onAreaNodeUnregstered: function() { this.handler(); }
};
Components.utils.import("resource:///modules/CustomizableUI.jsm");
CustomizableUI.addListener(CUIListener);

Bonus points for filtering those events for your widget ids only. :)
Useful information about CustomizableUI and its listeners if you'd like: https://developer.mozilla.org/docs/Mozilla/JavaScript_code_modules/CustomizableUI.jsm#Listeners

@Quicksaver Quicksaver referenced this issue in Quicksaver/Puzzle-Toolbars Dec 6, 2014
Closed

QuickJava buttons erroneously red until refreshed #64

@ThatOneGuyDotNet
Owner

Version 2.0.6 should fix this issue and has been submitted for review.

To install 2.0.6 early visit this page:
https://addons.mozilla.org/en-us/firefox/addon/quickjava/versions/

Thanks to @Quicksaver for the code snippet

@Quicksaver

You're very welcome, I'm glad it worked. :) Just wanted to confirm that everything works great for me with QJ's buttons with all (puzzle) toolbars and the menu panel as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment