Skip to content

How to update control's color using CSS once the control is created? #3082

Answered by ptziegler
ethanyhou asked this question in Q&A
Discussion options

You must be logged in to vote

@ethanyhou I'm by no means an expert in CSS, but isn't the issue simply that the class isn't updated recursively for all widgets?

i.e. this PoC seems to behave like your snippet with the hardcoded values:

private void updateControlBackground(Control control, boolean selected) {
	// Update CSS ID for styling consistency
	updateControlBackground2(control, selected);

	// Force color update programmatically to override CSS
	IStylingEngine engine = PlatformUI.getWorkbench().getService(IStylingEngine.class);
	if (engine != null) {
		// engine.style(control);
		engine.setClassname(control,
				selected ? "quick-start-feature-card-selected" : "quick-start-feature-card");
		engine.style(control);…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@iloveeclipse
Comment options

@ethanyhou
Comment options

@iloveeclipse
Comment options

@ethanyhou
Comment options

Comment options

You must be logged in to vote
2 replies
@ptziegler
Comment options

Answer selected by ethanyhou
@ethanyhou
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants