2014-01-26 3 views

답변

1

버전 1.15 이후 애드온 SDK는 도구 모음을 작성하고 버튼을 추가 할 수 있습니다. 수직 도구 모음을 만들 수는 없지만 가로 도구 만 만들 수 있다고 생각합니다.

/* This Source Code Form is subject to the terms of the Mozilla Public 
* License, v. 2.0. If a copy of the MPL was not distributed with this 
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 
"use strict"; 

const { Toolbar } = require("sdk/ui/toolbar"); 
const { Frame } = require("sdk/ui/frame"); 
const { Button } = require("sdk/ui/button"); 

let button = new Button({ 
    id: "button", 
    label: "send!", 
    icon: "./favicon.ico", 
    onClick:() => { 
    frame.postMessage({ 
     hello: "content" 
    }); 
    } 
}); 

let frame = new Frame({ 
    url: "./index.html", 
    onAttach:() => { 
     console.log("frame was attached"); 
    }, 
    onReady:() => { 
     console.log("frame document was loaded"); 
    }, 
    onLoad:() => { 
     console.log("frame load complete"); 
    }, 
    onMessage: (event) => { 
     console.log("got message from frame content", event); 
     if (event.data === "ping!") 
     event.source.postMessage("pong!", event.source.origin); 
    } 
}); 

let toolbar = new Toolbar({ 
    items: [frame], 
    title: "Addon Demo", 
    hidden: false, 
    onShow:() => { 
    console.log("toolbar was shown"); 
    }, 
    onHide:() => { 
    console.log("toolbar was hidden"); 
    } 
}); 

또한, 거기에 an older SO thread 애드온 SDK의 이전 버전과 XUL 기반의 애드온을 위해 작업을 수행하는 방법을 설명 :

Addon SDK official repository에서 작업을 수행하는 방법에 대한 좋은 예는있다.

0

위의 코드는 Firefox Australis에서만 사용할 수 있습니다 (upcomming 29.0 버전). toolbarwidget-jplib by Rob--W과 같은 Jetpack 모듈을 사용할 수 있습니다.

그래서 당신은 탐색 모음에서 위젯을 추가 할 수 있습니다 :이 링크는 질문에 대답 할 수

require("toolbarwidget").ToolbarWidget({ 
toolbarID: "nav-bar", // <-- Place widget on Navigation bar 
id: "mozilla-icon", 
label: "My Mozilla Widget", 
contentURL: "http://www.mozilla.org/favicon.ico" 
}); 
+1

하지만, 여기에 해답의 본질적인 부분을 포함하고 참조 할 수 있도록 링크를 제공하는 것이 좋습니다. 링크 된 페이지가 변경되면 링크 전용 답변이 유효하지 않게 될 수 있습니다. –

+1

정보 주셔서 감사합니다, 나는 답변을 편집했습니다. – Thompsen

관련 문제