Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

How would you use a javascript function to format all buttons

Avatar

Level 2

How would you go about using a function to change button format in one place?  I think the function needs to identify which button called it instead of using "this"?

Currently I put code in each buttons events see below for a sample.

LP.Pg3.PgBody.rowSFrmLP.sfrmBtn.Remove::mouseEnter - (JavaScript, client)

// set caption to red and underlined

this.caption.font.underline = "1";

this.caption.font.fill.color.value = "255,0,0";

 

LP.Pg3.PgBody.rowSFrmLP.sfrmBtn.Remove::mouseExit - (JavaScript, client)

// set caption to black and no underline

this.caption.font.underline = "0";

this.caption.font.fill.color.value = "0,0,0";

I would like to do something like the following code assigned each button to make it easier to maintain and I could simply change the function to change all the buttons formatting at once.

function fMouseIn()
{
// set caption to red and underlined
this.caption.font.underline = "1";
this.caption.font.fill.color.value = "255,0,0";
}

function fMouseOut()
{
// set caption to black and no underline
this.caption.font.underline = "0";
this.caption.font.fill.color.value = "0,0,0";
}

LP.Pg3.PgBody.rowSFrmLP.sfrmBtn.Remove::mouseEnter - (JavaScript, client)

sFrm.MouseIn();

 

LP.Pg3.PgBody.rowSFrmLP.sfrmBtn.Remove::mouseExit - (JavaScript, client)

sFrm.MouseOut();

1 Accepted Solution

Avatar

Correct answer by
Level 2

Now I get to play and see if I can make a single function for Instance manager buttons

What let me solve this was Is there a way to know which subform button was clicked?  Answered by radzmar

function fMouseIn()
{
// xfa.host.messageBox("The button '" + xfa.context.name + "' (" + xfa.context.somExpression + ") event triggerred.");
// set caption to red and underlined
var MyButton = xfa.context;
MyButton.caption.font.underline = "1";
MyButton.caption.font.fill.color.value = "255,0,0";
}

function fMouseOut()
{
// xfa.host.messageBox("The button '" + xfa.context.name + "' (" + xfa.context.somExpression + ") event triggerred.");
// set caption to black and no underline
var MyButton = xfa.context;
MyButton.caption.font.underline = "0";
MyButton.caption.font.fill.color.value = "0,0,0";

1 Reply

Avatar

Correct answer by
Level 2

Now I get to play and see if I can make a single function for Instance manager buttons

What let me solve this was Is there a way to know which subform button was clicked?  Answered by radzmar

function fMouseIn()
{
// xfa.host.messageBox("The button '" + xfa.context.name + "' (" + xfa.context.somExpression + ") event triggerred.");
// set caption to red and underlined
var MyButton = xfa.context;
MyButton.caption.font.underline = "1";
MyButton.caption.font.fill.color.value = "255,0,0";
}

function fMouseOut()
{
// xfa.host.messageBox("The button '" + xfa.context.name + "' (" + xfa.context.somExpression + ") event triggerred.");
// set caption to black and no underline
var MyButton = xfa.context;
MyButton.caption.font.underline = "0";
MyButton.caption.font.fill.color.value = "0,0,0";