SRAZZANO ...

General discussion about Custom Buttons, including feature requests.

Re: SRAZZANO ...

Postby srazzano » Thu Jan 04, 2018 8:46 am

For your insert buttons, this is the code block that more than likely needs to be changed:
Code: Select all
var params = Cc["@mozilla.org/embedcomp/command-params;1"].createInstance(Ci.nsICommandParams);
var controller = document.commandDispatcher.getControllerForCommand(command);
if (controller && controller.isCommandEnabled(command)) {
  params.setStringValue("state_data", text);
  controller.QueryInterface(Ci.nsICommandController).doCommandWithParams(command, params);
}

To something like this, but need to define the value for text:
Code: Select all
let tb = wm("navigator:browser").content.document.activeElement,
     text = e.target.src,
     s1 = tb.value.substr(0, tb.selectionStart),
     s2 = tb.value.substr(tb.selectionEnd);
 tb.value = s1 + text + s2;
let posSel = s1.length + text.length;
tb.focus();
tb.setSelectionRange(posSel, posSel);

Missing any character/digit/punctuation in javascript will cause problems and many users try to avoid tinkering with it.
Made a minor update to Insert Smiley 2 Full. Tip: If you put your images in xHTML tab, it will override the HTML tab and you won't lose them with any future updaates of the button. Same with the other xCSS tabs. xCSS overrides CSS tab, xCSS2 overrides CSS2, and so on. The x'ed tab get put in your about:config so you never lose them on an update. I do not code in the x'ed tabs.
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada

Re: SRAZZANO ...

Postby BobbyW » Thu Jan 04, 2018 9:25 am

srazzano wrote:For your insert buttons, this is the code block that more than likely needs to be changed:
Code: Select all
var params = Cc["@mozilla.org/embedcomp/command-params;1"].createInstance(Ci.nsICommandParams);
var controller = document.commandDispatcher.getControllerForCommand(command);
if (controller && controller.isCommandEnabled(command)) {
  params.setStringValue("state_data", text);
  controller.QueryInterface(Ci.nsICommandController).doCommandWithParams(command, params);
}

To something like this, but need to define the value for text:
Code: Select all
let tb = wm("navigator:browser").content.document.activeElement,
     text = e.target.src,
     s1 = tb.value.substr(0, tb.selectionStart),
     s2 = tb.value.substr(tb.selectionEnd);
 tb.value = s1 + text + s2;
let posSel = s1.length + text.length;
tb.focus();
tb.setSelectionRange(posSel, posSel);



Can you please elaborate with maybe an example.....using a line of code from the button I posted, with the text values inserted....once I know the right spot to place the text, I think I can cruse from there...

Is it maybe s1 & s2 in this: tb.value = s1 + text + s2; ??


Thanks Image
BobbyW
 
Posts: 263
Joined: Sat Dec 31, 2011 6:03 am

Re: SRAZZANO ...

Postby srazzano » Thu Jan 04, 2018 9:42 am

This is your BBCode button fixed, just substitute var text = with what ever you are trying to insert:
Code: Select all
/*CODE*/
var tb = gBrowser.contentWindow.document.activeElement, sel;
sel = tb.value.substring(tb.selectionStart, tb.selectionEnd);
var text = "[b]" + sel + "[/b]",
    s1 = tb.value.substr(0, tb.selectionStart),
    s2 = tb.value.substr(tb.selectionEnd);
tb.value = s1 + text + s2;
var posSel = s1.length + text.length;
tb.focus();
tb.setSelectionRange(posSel, posSel);

Seems to me, you could have a dropdown menu with various formats to choose from for the selected text, instead of just bold.
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada

Re: SRAZZANO ...

Postby BobbyW » Thu Jan 04, 2018 10:02 am

No, actually the BB CODE Button is just a stand alone button....it just places the code on selected text within the text edit box like I use here on this line. I just dragged through & highlighted the above text in the edit box, pressed the button, & it applied Bold & Italic BBcodes to the selected text....

It's just one of many other buttons I make using different codes, which forms forms a drop-down menu, when used in a Button Stacker button.

So the button I posted, when working will be either used stand-alone, or in a stacker button to select from a menu of code variations.....30+ buttons for 30+ code variations.......into 1 Button Stacker Button.....

I post on different forums, & some have unique code variations.....so I have a few stacker button "menu" buttons suited for each....

Image


Each menu item represents one button.....which I will mix & match depending on my needs....it's ever changing....
BobbyW
 
Posts: 263
Joined: Sat Dec 31, 2011 6:03 am

Re: SRAZZANO ...

Postby srazzano » Thu Jan 04, 2018 10:11 am

Your Clippings button really needs to be overhauled and made more efficient/simplified.
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada

Re: SRAZZANO ...

Postby BobbyW » Thu Jan 04, 2018 10:14 am

srazzano wrote:Your Clippings button really needs to be overhauled and made more efficient.


It works perfectly to WF54....since 2008, but in WF56 it just wont let me post into the edit box.

If it did, I'd be using that button 'till hell freezes over......it's perfect for what I needed....until WF56 that is....
BobbyW
 
Posts: 263
Joined: Sat Dec 31, 2011 6:03 am

Re: SRAZZANO ...

Postby srazzano » Thu Jan 04, 2018 10:39 am

Has the same issue in that it's using the commandDispatcher function.
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada

Re: SRAZZANO ...

Postby BobbyW » Thu Jan 04, 2018 11:16 am

srazzano wrote:Has the same issue in that it's using the commandDispatcher function.



That's all Greek to me....I'm a user....not a maker..
BobbyW
 
Posts: 263
Joined: Sat Dec 31, 2011 6:03 am

Re: SRAZZANO ...

Postby makondo » Thu Jan 04, 2018 5:20 pm

srazzano,
what do you mean by this:"If you put your images in xHTML tab..."? You mean urls to images? But isn't it in the CSS3? I still can't figure what HTML tab is for.
makondo
 
Posts: 1653
Joined: Sun Dec 25, 2011 7:17 pm

Re: SRAZZANO ...

Postby srazzano » Thu Jan 04, 2018 8:29 pm

HTML and xHTML tab sections are just another available areas to put in whatever. It could of well have been CSS5 and xCSS5, but wanted to emphasize that other than css could be used, thus I put the image names and src's there. All the different tab sections clump similar css code blocks in one area to keep the initialization section less cluttered. Example: Setting dialog css in CSS tab, popup css in CSS2 tab, scrollbar css in CSS3 tab and so on. All the x'ed tabs override their adjacent CSS or HTML tabs and thus will not get overwritten with updates.
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada

PreviousNext

Return to General Discussion

cron