I liked Jay's answer to my previous question about accessing OS color
pickers.

I'm taking the plunge, and trying to get the jscolorXS picker (smaller
derivative of the respected jscolor picker) to work in a script. The project
page has a simple demo I'm trying to duplicate, as a test:

http://www.dematte.at/jscolorXS/

I've got it halfway working. The inputs are properly colorized to their
values. Clicking on them shows and hides the picker. But, the picker is
apparently not receiving its clicks, so there is no cursor movement or color
change.

I guess it's something about when the code is run, or scope, maybe. Probably
relevant -- I often use event listeners to capture user input. Have not used
unsafewindow, which I don't fully grasp.

I'm assuming this can be done. But, I've found precious little on the 'net,
regarding color pickers in user scripts. Would appreciate a hand. Test code
follows. Thank you

// ==UserScript==
// @name           Color Test
// @description    test color picker
// @include        *
// @require        http://www.dematte.at/jscolorXS/jscolor_src.js

// ==/UserScript==

// Start

(function() {

function HSXcolortest_Run(){

    var colorDiv = document.createElement("div");

    colorDiv.innerHTML = "<h2>Demo:</h2><p><input class='color'
value='#FF0000' /><input class='color' value='#C0F399' /><input
class='color' value='#34CA00' /></p>";

    colorDiv.id = "colorPanel";
    colorDiv.style.position = "fixed";
    colorDiv.style.display = "block";
    colorDiv.style.backgroundColor = "#F3F3F3";
    colorDiv.style.zIndex = "104";
    colorDiv.style.borderWidth = "1px";
    colorDiv.style.borderStyle = "solid";
    colorDiv.style.borderColor = "black";

    //--- place new panel into HTML

    var findbody = document.evaluate("//body", document, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    var item = findbody.snapshotItem(0);
    item.insertBefore(colorDiv, item.firstChild);
}

HSXcolortest_Run();

})();
// End

-- 
View this message in context: 
http://old.nabble.com/trouble-getting-color-picker-functional-tp31302802p31302802.html
Sent from the GreaseMonkey List mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to