cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Custom Style Definition (image) updation in runtime Button Hover?

jaswanth
12-Amethyst

Custom Style Definition (image) updation in runtime Button Hover?

I am trying to update Style Definition through a service and I have done updating background color and font color but unable to update image.How to Update Image in it? I used code below to update style through bindings.

(updatePropertyInfo.TargetProperty === 'Style') {
var LabelStyle = TW.getStyleFromStyleDefinition(this.getProperty('Style', 'DefaultLabelStyle'));
var currentTextSizeClass = TW.getTextSizeClassName(LabelStyle.textSize);

this.setProperty('Style', updatePropertyInfo.SinglePropertyValue);
LabelStyle = TW.getStyleFromStyleDefinition(this.getProperty('Style', 'DefaultLabelStyle'));
LabelStyle = (LabelStyle.styleDefinitionName === undefined) ? TW.getStyleFromStyleDefinition('DefaultLabelStyle') : LabelStyle;

var element = this.jqElement.find('.label-text');
element.removeClass(currentTextSizeClass);
element.addClass(TW.getTextSizeClassName(LabelStyle.textSize));
var LabelStyleText = TW.getStyleCssTextualNoBackgroundFromStyle(LabelStyle);
element.css(convertStyleToCssObj(LabelStyleText));
(!LabelStyle.foregroundColor.length > 0) ? element.css('color', '') : '';
document.getElementById(thisWidget.jqElementId).style.cssText += TW.getStyleCssGradientFromStyle(LabelStyle) + LabelStyleText;
}
};

var convertStyleToCssObj = function(style) {
var styleObjResult = {};
var styleArray = style.split(';');
for (var i = 0; i < styleArray.length; i++) {
var propertyArray = styleArray[i].split(':');
styleObjResult[propertyArray[0].replace(/\s/g, '')] = propertyArray[1];
}
return styleObjResult;
};

Can any one suggest changes in code or Is there any other way

my requirement is to show a style(style definition) having binding in a button widget

ACCEPTED SOLUTION

Accepted Solutions
jaswanth
12-Amethyst
(To:slangley)

I used Image Overlay(Search Google for css_image_overlay_fade) with this we can get image over hover but I was unable to do this through CSS updation during Runtime

View solution in original post

5 REPLIES 5
PaiChung
22-Sapphire I
(To:jaswanth)

I believe if you use an image widget, the image itself is bindable, so you can run a service to resolve what media entity you want to display and return that and bind that to the widget.

jaswanth
12-Amethyst
(To:PaiChung)

My requirement is to show a image on Button Hover and How can i make the Image widget visible when its Hovered over the Button(Is there a way to check button hover and give image)and I want to know how to update style Definition Image cause there is a way to update foreground,background through above code.

PaiChung
22-Sapphire I
(To:jaswanth)

For Hover OOTB we only support an 'On Hover' Style definition. (No events to run a service)

Beyond that you'd have to use CSS and I'm not very good with CSS

slangley
23-Emerald II
(To:jaswanth)

Hi @jaswanth.

 

If you have found a solution to your problem, please feel free to post it here and mark it as the Accepted Solution for the benefit of others on the community.

 

Regards.

 

--Sharon

jaswanth
12-Amethyst
(To:slangley)

I used Image Overlay(Search Google for css_image_overlay_fade) with this we can get image over hover but I was unable to do this through CSS updation during Runtime

Announcements


Top Tags