Search Box/Bar

User Help for Mozilla Firefox
Post Reply
Briar2345
Posts: 39
Joined: December 20th, 2017, 9:43 am

Search Box/Bar

Post by Briar2345 »

Good Afternoon,

Clear the (separate) search box or at least stop it from selecting whatever is in there ?

Now that the useful addon Clear Inputs no longer works ...

I managed to stop the URL bar from becoming selected, but still have to find a way to clear it and do the same for the search bar.

Regards

Briar
User avatar
Reflective
Posts: 2283
Joined: February 15th, 2007, 11:13 am

Re: Search Box/Bar

Post by Reflective »

User avatar
Frank Lion
Posts: 21177
Joined: April 23rd, 2004, 6:59 pm
Location: ... The Exorcist....United Kingdom
Contact:

Re: Search Box/Bar

Post by Frank Lion »

For the searchbar, I just do Ctrl + K and start typing the new search term and it overwrites anything already there. To clear it, you could do Ctrl + K, then Delete.

Btw addressbar (urlbar) is Ctrl + L
"The only thing necessary for the triumph of evil, is for good men to do nothing." - Edmund Burke (attrib.)
.
nohamelin
Posts: 96
Joined: September 3rd, 2013, 4:04 pm
Location: Chile

Re: Search Box/Bar

Post by nohamelin »

I have a button to clean the respective textbox in the searchbar and the findbar added by a private add-on. As it's implemented via CSS+XBL, it can be added via userChrome.css in Fx57 and later. So:

1) In your userChrome.css goes the next lines:

Code: Select all

.searchbar-textbox > .search-go-container {
    -moz-binding: url('general.xbl#clear-searchbar');
}
.findbar-textbox > .textbox-input-box {
    -moz-binding: url('general.xbl#clear-findbar');
}
#clear-searchbar-button {
    padding: 3px 2px 3px 0;
}
The padding values need be ajusted to make the icon to look good.

2) And the next code need be pasted in a new text file called general.xbl and placed in the same folder next to userChrome.css:

Code: Select all

<?xml version="1.0"  encoding="UTF-8" ?>

<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:xbl="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <binding id="clear" extends="xul:hbox">
        <resources>
            <stylesheet src="chrome://global/skin/textbox.css"/>
        </resources>

        <implementation>
            <property name="textbox">
                <getter><![CDATA[
                    var node = this;
                    while (node.localName != "textbox") node = node.parentNode;
                    return node;
                    ]]>
                </getter>
            </property>

            <method name="reset">
                <body><![CDATA[
                    this.textbox.reset();
                    this.textbox.focus();
                    ]]>
                </body>
            </method>
        </implementation>
    </binding>

    <binding id="clear-searchbar" extends="#clear">
        <content>
            <xul:image id="clear-searchbar-button"
                       class="lsak-clear-button textbox-search-clear"
                       tooltiptext="Clear Field"
                       onclick="document.getBindingParent(this).reset();"/>
            <children/>
        </content>
    </binding>

    <binding id="clear-findbar" extends="#clear">
        <content>
            <children/>
            <xul:image id="clear-findbar-button"
                       class="lsak-clear-button textbox-search-clear"
                       tooltiptext="Clear Field"
                       onclick="document.getBindingParent(this).clear();"/>
        </content>

        <implementation>
            <method name="clear">
                <body><![CDATA[
                    this.reset();
                    this.textbox.findbar._find(this.value);
                    ]]>
                </body>
            </method>
        </implementation>
    </binding>
</bindings>
I haven't updated the XBL code since... Fx 30~40?, but it seems to work in current Nightly, mostly: there is some minor quirks with the searchbar. I don't have the time now to fix it, but I will give to it a revision when I myself move to ESR 60. Maybe I can restore the button in the address bar too.

Also be aware that it will not work anymore around Firefox 61(?), as the XBL technology is being removed from Firefox.
Post Reply