Updating UI of firefox addon using sdk -
Updating UI of firefox addon using sdk -
i writing simple firefox addon using addon-sdk-1.17 . having problem updating ui of addon. if cfx run, addon looks normal, if "cfx xpi" , load profile has previous version of addon, thats run problems.
a simple illustration of can seen illustration mozilla has in toolbar tutorial. can found at: https://developer.mozilla.org/en-us/add-ons/sdk/low-level_apis/ui_toolbar
if bundle (cfx xpi) next code (assuming icons , html file exist), works expected:
var { actionbutton } = require('sdk/ui/button/action'); var { toolbar } = require("sdk/ui/toolbar"); var { frame } = require("sdk/ui/frame"); var previous = actionbutton({ id: "previous", label: "previous", icon: "./icons/previous.png" }); var next = actionbutton({ id: "next", label: "next", icon: "./icons/next.png" }); var play = actionbutton({ id: "play", label: "play", icon: "./icons/play.png" }); var frame = new frame({ url: "./frame-player.html" }); var toolbar = toolbar({ title: "player", items: [previous, next, play, frame] });
but if want add together additional button , decide alter url of frame, don't update toolbar. example, after loading above addon profile, if create next changes main.js:
var { actionbutton } = require('sdk/ui/button/action'); var { toolbar } = require("sdk/ui/toolbar"); var { frame } = require("sdk/ui/frame"); var previous = actionbutton({ id: "previous", label: "previous", icon: "./icons/previous.png" }); var next = actionbutton({ id: "next", label: "next", icon: "./icons/next.png" }); var play = actionbutton({ id: "play", label: "play", icon: "./icons/play.png" }); var mute = actionbutton({ id: "mute", label: "mute", icon: "./icons/mute.png" }); var frame = new frame({ url: "./new-frame-player.html" }); var toolbar = toolbar({ title: "player", items: [previous, next, play, mute, frame] });
the toolbar not have either (frame-player.html or new-frame-player.html) loaded on toolbar, , mute button not located on toolbar either. again, works fine "cfx run" or if install addon profile doesn't have previous version of addon.
i assume there dumb doing or there easy solution, haven't seen documentation on anywhere. not sure if overlooked or what.
the "problem" here is, firefox saves location buttons had been manually placed, when extension uninstalled. can reset info hitting "restore defaults" in cutomization tab.
alternatively can force-move frame using customizableui.jsm:
var customizableui = require("resource:///modules/customizableui.jsm"); customizableui.addwidgettoarea(frame.id, "inner-" + toolbar.id);
or if want move button:
var cutomizableui = require("resource://modules/customizableui.jsm"); var { getnodeview } = require("sdk/view/core"); customizableui.addwidgettoarea(getnodeview(button).id, "inner-" + toolbar.id);
firefox-addon firefox-addon-sdk xul
Comments
Post a Comment