Allow the user to choose the background color of dialogue/pallet box

Hi all

So, basically, I'm trying to give the user the ability to customize a toolbar, I developed for work by allowing them to choose their own color. I don't want to have to keep jumping into the script whenever someone wants a different color then thought it would be an additional pleasure.

I looked and found the code for a color picker and suitable for what I want, but being a complete noob, I

(a) clearly hurts because it does not work and

(b) there is probably a better way to do it.

You will see below my script for a fake dialog window.

Any help would be greatly appreciated.

var box = new Window("dialog", "Just Digital Toolbar");  
  
box.panel1 = box.add('panel', undefined);  
box.panel1.group = box.panel1.add('group', undefined );  
box.panel1.group.orientation='row';  
  
box.panel1.group.finalBtn = box.panel1.group.add('button',undefined, "Dummy 1", {name:'dummy1'});  
box.panel1.group.binderBtn = box.panel1.group.add('button',undefined, "Dummy 2", {name:'dummy2'});
box.panel1.group.bocBtn = box.panel1.group.add('button',undefined, "Dummy 3", {name:'dummy3'});


box.panel2 = box.add('panel', undefined);  
box.panel2.group = box.panel2.add('group', undefined, );  
box.panel2.group.orientation='row';  
  
box.panel2.group.colourPickBtn = box.panel2.group.add('button',undefined, "Colour Picker", {name:'colourPick'});
box.panel2.group.closeBtn = box.panel2.group.add('button',undefined, "Close", {name:'close'});


box.location = [1850, 40];


box.panel2.group.colourPickBtn.onClick = function(){  
    
var hexToRGB = function(hex) {
  var r = hex >> 16;
  var g = hex >> 8 & 0xFF;
  var b = hex & 0xFF;
  return [r, g, b];
};

var color_decimal = $.colorPicker();
$.writeln(color_decimal);

var color_hexadecimal = color_decimal.toString(16);
$.writeln(color_hexadecimal);

var color_rgb = hexToRGB(parseInt(color_hexadecimal, 16));
$.writeln(color_rgb);

var color_that_ae_add_solid_understands = [color_rgb[0] / 255, color_rgb[1] / 255, color_rgb[2] / 255];
$.writeln(color_that_ae_add_solid_understands);

box.graphics.backgroundColor = color_rgb;
}

//===================TEMP CLOSE FUNCTION=====================//
box.panel2.group.closeBtn.onClick = function(){  
  box.close();
}
//===================TEMP CLOSE FUNCTION END=====================//

box.show ();

The piece of code I posted was intended to replace box.graphics.backgroundColor = color_rgb;

Full code (without the .writeln of $):

function hexToRGB(hex) {
    var r = hex >> 16;
    var g = hex >> 8 & 0xFF;
    var b = hex & 0xFF;
    return [r, g, b];
    };

var box = new Window("palette", "Just Digital Toolbar");    

box.panel1 = box.add('panel', undefined);
box.panel1.group = box.panel1.add('group', undefined );
box.panel1.group.orientation='row';    

box.panel1.group.finalBtn = box.panel1.group.add('button',undefined, "Dummy 1", {name:'dummy1'});
box.panel1.group.binderBtn = box.panel1.group.add('button',undefined, "Dummy 2", {name:'dummy2'});
box.panel1.group.bocBtn = box.panel1.group.add('button',undefined, "Dummy 3", {name:'dummy3'});  

box.panel2 = box.add('panel', undefined);
box.panel2.group = box.panel2.add('group', undefined, );
box.panel2.group.orientation='row';    

box.panel2.group.colourPickBtn = box.panel2.group.add('button',undefined, "Colour Picker", {name:'colourPick'});
box.panel2.group.closeBtn = box.panel2.group.add('button',undefined, "Close", {name:'close'});  

box.location = [1850, 40];  

box.panel2.group.colourPickBtn.onClick = function(){
    var g = box.graphics;
    var color_decimal = $.colorPicker();
    if (color_decimal>=0){
        var color_hexadecimal = color_decimal.toString(16);
        var color_rgb = hexToRGB(parseInt(color_hexadecimal, 16));
        var color_that_ae_add_solid_understands = [color_rgb[0] / 255, color_rgb[1] / 255, color_rgb[2] / 255];    

        g.backgroundColor = g.newBrush(g.BrushType.SOLID_COLOR, color_that_ae_add_solid_understands);
        };
    }  

//===================TEMP CLOSE FUNCTION=====================//
box.panel2.group.closeBtn.onClick = function(){
  box.close();
}
//===================TEMP CLOSE FUNCTION END=====================//  

box.show ();

Xavier

Tags: InDesign

Similar Questions

  • How do you define the background color for a text box

    In older versions, that I was able to set the background color in a text box, I want to do the same in this newer version and I can not find where I would choose this option

    Hi alanb.

    Please type your text in the text box, now in the right pane of comments you will see your text, right click & Select "Properties".

    In the properties box, select the fill color to fill in the color in the text box.

    I would like to know if it works.

    Kind regards

    Nicos

  • Is there a way to make the background color of a check box change depending on the State, in that it is?

    As: Green background when checked and white background (neutral), while not controlled.  Management wants to draw attention to areas that have been selected.

    If you create a script by right-clicking form1 object in your hierarchy (which is the subform above) and click on create a Script object and then insert into the function below script object:

    function changeColor (rootObject) {/ /}<--Refers to="" the="" object="" itself="">

    If (rootObject.rawValue! = null: rootObject.rawValue! = 0) {}

    rootObject.border.fill.presence = 'hidden ';

    } else {}

    rootObject.border.fill.presence = "visible";

    }

    }

    From there the Action Builder, you can use 'A Script object function call' then choose your item and choose the function changeColor. This should do the trick for you. This will show or hide the background color of your field.

    If you want to change the color instead of hide or show, you can use this function at the bottom and change the RGB value to your liking:

    function changeColor (rootObject) {/ /}<--Refers to="" the="" object="" itself="">

    If (rootObject.rawValue! = null: rootObject.rawValue! = 0) {}

    rootObject.border.fill.color.value = "255,255,255"; 255,255,255 represents white, no colour

    } else {}

    rootObject.border.fill.presence = "0,255,64";

    }

    }

  • Setting the background color of a TextArea

    I was not able to set the background color of a text box. Here's what I try and it works for the other components.

    ****************************************************************

    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    import javafx.scene.control.TextArea;
    
    public class TextAreaTest extends Application{
      public void start(Stage stage){
        TextArea area = new TextArea();
        area.setStyle("-fx-background-color: black; -fx-text-fill: lightgreen;");
        Scene s = new Scene(area);
        stage.setTitle("black text area");
        stage.setScene(s);
        stage.show();
      }
      public static void main(String[] args){
        launch(args);
      }
    
    }
    

    ***************************************************************

    I use jdk 8 with whatever version javafx is included. I searched a bit on the internet and I think I see mixed results using this technique.

    Thank you.

    In an external css file, do

    .text-area .content {
       -fx-background-color: black ;
    }
    
  • Choosing a color gives the background color?

    Whenever I take a color by dropper or the tab of shades, it affects him my background color. It allows to define my foreground color. How can I change this?

    Look in the color Panel. You have probably highlighted the background color. Click the foreground color in the Panel, and you should be good to go.

  • How to set the background colors of different message by account?

    I have two email accounts (let's say a private one for companies) in Thunderbird. Sometimes I (wrongly) mail on the wrong account. That is, I read some messages in a single account, followed by reading in the other account. I hit 'empty' to send a message and be sure to make sure I'm in the right account, that I want to mail to. Every now and then post to the wrong account, get the name wrong 'sender' and I ' answer to "name of the message.

    I looked at the account settings and found I can change the background color (in the e-mails triggered and and sent in the mail while composing). I changed the background color in a SINGLE account (in light yellow) and expects the other account be unchanged (white). Not the case. Change the background color in the account for a single account settings changes the color in all accounts (both).

    It is unexpected and unwanted, and my problem is still there.

    There is an add-on that accounts of color coding and records:

    https://addons.Mozilla.org/en-us/Thunderbird/addon/account-colors/

    and also the modules allowing to choose the correct identity:

    https://addons.Mozilla.org/en-us/Thunderbird/addon/identity-Chooser/

    https://addons.Mozilla.org/en-us/Thunderbird/addon/correct-identity/

    http://chrisramsden.vfast.co.UK/3_How_to_install_Add-ons_in_Thunderbird.html

  • Change the background color of a table cell, depending on the selection in a drop-down list

    I have a drop-down list wrapped in a subform in a table cell. Users can choose green, yellow or red, and I want the background color to change according to their choice.

    Can you tell me why this script does not work? I'm sure that some of you, dear friends can see in a second.


    If (this. ListItem == "green") {}

    Subform1.DropDownList1.fillColor = "000,128,000"; BackgroundFill = "solid";

    }

    If (this. ListItem == 'yellow') {}

    Subform1.DropDownList1.fillColor = "255,128,000";

    }

    If (this. ListItem == 'red') {}

    Subform1.DropDownList1.fillColor = "255,000,000;

    }


    Thank you

    Hello

    I think you should be able to use the following code in the event change of the dropdownlist control.

    Form1. #subform [0]. Table1.row2.DropDownList1::change - (JavaScript, client)

    If {(xfa.event.change=="green)"}

    this.fillColor = "000,128,000";

    }

    If {(xfa.event.change=="yellow)"}

    this.fillColor = "255,128,000";

    }

    If {(xfa.event.change=="red)"}

    this.fillColor = "255,000,000;

    }

    Concerning

    Bruce

  • How can I change the background color by default for a Web page where none is specified?

    There are many versions I've customized the background color if none has been given to brown to go with the skin I used then.

    Now, I find with a simple text file is not readable with black against Brown, but I can't find today's version where to put them back to white (or at least a pale color).

    Any help appreciated.

    I think it must be the "Background" parameter in the following dialog box:

    the button Firefox orange (or the Tools menu) > Options > content > button "colors".

    Which leaves you choose something lighter for pages that do not define their own color?

  • You can change the background color vi with a property node?

    I was wondering if it was possible in Labview to use a property node to change the background color of façade for an iteration, then back to an original color later. I don't think it's possible, but I would like to know for sure.

    Thank you

    Jody

    You can get the property pane directly node by right-clicking the scroll bar on the front panel and create-> property Node-> color pane.  Useful with multiple panes.  You can also click the property pane node in example of (imstuck) and choose link and then select the pane.

  • Change the background color of line indicator

    I'm doing an indicator of string with a black background or make it to which the channel indicator is transparent

    Thank you

    You can change the background color of the control a chain using the paint tool. Choose View > Tool Palette.

    Select the icon below a brush.

    Right-click on the background area of your control of the chain.

    A color mixer will appear - select a color block or the T in the upper right corner to transparent.

  • Active window color problem - cannot change the background color

    original title: Active window color problem

    By right-clicking: Desktop, then click on: personalization / window color and appearance / settings (Advanced) appearance, Windows user can assign a background color of the active window in any application.  This is useful for those of us who don't want a stark white screen; We can assign a mild pastel tint which may be easier on the eyes for long term sessions.

    At some recent point, I lost the background color of the active window within Windows uses 'household.  I still not my background color assigned in any application I run (Word, Mail, etc.), but using Windows Explorer to navigate through my hard drive, the active window is now always the default stark white Windows.  How this change and can it be forced to adhere to the assigned active window background color?

    Hello

    Step 1: Check if the problem continues in a new user account.

    http://Windows.Microsoft.com/en-us/Windows-Vista/what-is-a-user-account

    Step 2: If the problem does not persist in a new user account, then the old profile could have been corrupted. Try the following article to fix a corrupted user profile.

    http://Windows.Microsoft.com/en-us/Windows-Vista/fix-a-corrupted-user-profile

  • How can I change the background color under Windows 7 64-bit

    How to get the background color of the screen to change.  I went through the customization of themes and custom colors that changed some screens, but not all.  I've recently updated to XP and I find it frustrating.  For example, when you use ITunes, my desktop background is white which is difficult to focus on for long periods of time.  On my XP machine, I was able to change the background of a light gray.  Help, please.

    In fact it's not Windows, it's iTunes.  The latest version is very white (and very hard on the eyes).  It seems just as bad on XP, you probably just the previous version of iTunes before you upgrade.  Unfortunately, Apple is the only one who can change - it program iTunes, and they do not meet the standard rules of "respect the choice of the users!

    If this was helpful, please vote. If it solves the problem, please click on propose as answer. Thank you!

  • How to set the background color for the Webworks Menu?

    Hi all

    I have developed a web application that uses the emulator to ripple and Blackberry Webworks SDK 2.3.1.5.In I added the Menu items on the Blackberry Menu button... It works well... It contains the background color by default for Menu (Black)... Here, I want to change the background color of the Menu... Please help me to change the background color... Thank you very much..

    With respect,

    Marimuthu_P

    I don't think that this is possible.  The WebWorks API allows you to add menu items to your application does not provide the ability to change the background color by default of the menu.

    This API is actually an extension of Java built into the SDK WebWorks.  The source code because it's open source, available here: https://github.com/blackberry/WebWorks/tree/master/api/menu/src/main/java/blackberry/ui/menu

    It is based on the Java class "MenuItem", which as you can see it does not provide methods or properties to set the color:

    http://www.BlackBerry.com/developers/docs/7.1.0api/NET/rim/device/API/UI/MenuItem.html

  • How can I change the background color on the welcome login page

    How can I change the background color to the aid of the background file, error 0x8000000A warned?

    [Original title: Welcome to the page]

    [Transferred from Internet Explorer]

    Hello

    Please try the suggestion of Mark L. Ferguson in the thread below.

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-desktop/Windows-7-background-on-user-login-page/d1f1e4b7-f3ca-4b88-8c05-7a2a63d31bc5

    Thank you

    Legaede

  • How can set the background color of the status bar?

    Quote from the old forum:

    Comments: comments
    How can set the background color of the status bar?
    Posted the: July 17, 2008 02:56
     
    How can set the background color of the status bar?
    Using this code for the status bar:
    LabelField statusField = new LabelField ("Good Morning", LabelField.USE_ALL_WIDTH |) LabelField.NON_FOCUSABLE | LabelField.HCENTER)
    {
    int _backgroundColour = Color.LIGHTGREEN;
    public void paint (Graphics g)
    {
    g.setBackgroundColor (Color.RED);
    g.Clear ();
    Super.Paint (g);
    }
    };

    Font defaultfont = Font.getDefault ();
    Police smallfont = defaultfont.derive (Font.PLAIN, 12);

    statusField.setFont (smallfont);
    setStatus (statusField);

    When I ran the code you have above, my status background color was red.  Is not what you see?  If so, please provide the BlackBerry model and software version that you are testing.  You can find this under Options.

    Or if you try to do something else, please provide details.

    I tested this in the BlackBerry Simulator included with version 4.5.0 BlackBerry JDE (4.5.0.44).

    To do this in version 4.1, first call getColor and save the current color.  Then call setColor, setting the color to the color you want to use for the background.  After this call call fillRect, starting with 0, 0 and go to the size of the field (use this.getWidth () and this.getHeight () to get this).  This must fill in the field with your specified color.

    To allow the drawing of the default content of the field call setColor once again, passing in the original color, then call super.paint.

Maybe you are looking for