Custom onsynctopreference for XUL textbox

Posted by Alexey Romanov on Stack Overflow See other posts from Stack Overflow or by Alexey Romanov
Published on 2010-12-26T07:47:44Z Indexed on 2010/12/26 7:53 UTC
Read the original article Hit count: 252

Filed under:
|

I wanted to enable custom shortcuts in my Firefox extension. The idea is that the user just focuses on a textbox, presses key combination, and it's shown in the textbox and saved to a preference. However, I couldn't get it to work. With this 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>

the event in onkeyup works. But when I click the OK button, I don't see a "syncing" alert. Why isn't onsynctopreference working? Is it impossible to have custom onsynctopreference attribute for a textbox?

© Stack Overflow or respective owner

Related posts about firefox-addon

Related posts about xul