簡體   English   中英

XUL文本框的自定義onsynctopreference

[英]Custom onsynctopreference for XUL textbox

我想在Firefox擴展中啟用自定義快捷方式。 這個想法是,用戶只需將焦點放在一個文本框上,按一下組合鍵,它就會顯示在文本框中並保存到首選項中。 但是,我無法正常工作。 有了這個XUL

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/skin/pref/pref.css" type="text/css"?>

<!DOCTYPE window SYSTEM "chrome://nextplease/locale/nextplease.dtd">
<prefwindow id="nextpleaseprefs" title="&options.title;" buttons="accept, cancel"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <prefpane id="nextplease.general" label="&options.general.title;" image="chrome://nextplease/skin/Sound Mixer.png">
        <preferences>
            <preference id="nextkey" name="nextplease.nextkey" type="int"/>
        </preferences>
        <vbox flex="1">
            <hbox align="center">
                <label value="&options.general.nextKey;" />
                <textbox id="nextkey" flex="1" editable="false" 
                         onkeyup="return nextplease.handleKeySelection(this, event);" 
                         preference-editable="true" preference="nextkey" 
                         onsynctopreference="alert('syncing'); return nextplease.syncKeySelector(this);"/>
            </hbox>
        </vbox>
    </prefpane>

    <script type="application/x-javascript" src="chrome://nextplease/content/nextpleaseCommon.js" />
    <script type="application/x-javascript" src="chrome://nextplease/content/nextpleaseOptions.js" />
</prefwindow>

onkeyup的事件起作用。 但是,當我單擊“確定”按鈕時, 沒有看到“正在同步”警報。 為什么onsynctopreference不起作用? 是否有可能為文本框提供自定義onsynctopreference屬性?

似乎問題在於,首選項僅在input事件(可能還有其他事件)上同步,而在keyup不同步。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM