Is there any way to have a Unity TextMeshPro dropdown option with a different font than the others in the list? - unity3d

I am using TextMeshPro Dropdowns in Unity as the basis for my menu system. The problem is Unity TMP Dropdowns require one option to be selected at all times, and clicking the already selected option won't trigger the "On Value Changed" function for processing the option.
Thus the only solution I am aware of is to have the first option be a dummy option like "CHOOSE:" or "SELECT ONE:" which is then the initially selected option. This is not too bad but it would be better if it was possible to at least make it a different font (for example, bold) so it looks intentional.
From what I can see however, there is no way to script or code anything to change the font size/color/face of only one option in a dropdown.
Is this possible or would there be another suggested solution to the problem?
Thanks.

You can use the RichText tags for setting string literals, something like
List < string > m_DropOptions = new List < string > { "<size=19><i>Select something</i></size>", "Option 1", "Option 2" };
Now Select something will be italic and with a different font size. You can always explore RichText link to find information that suite the needs of the application.
Output:

Related

How to separate option values and text in drop-down form control?

Editing a simple (so far) form in Kentico 11. I am creating a drop-down. All I want to do is to have the value of each rendered option and the visible text of each option be different, like this:
<option value="CatalogNumber">Product name</option>
so that when I refer to the Value property of the drop-down I get the (in this case) CatalogNumber, but the user sees the product name. This is surely something people do every day, but I can not find anything in the doc, or on DevNet, explaining how to do it. Am I missing something so obvious that no one finds it necessary to mention?

Make uib-typeahead behave like a select or format a select like uib-typehead?

is it possible to make a uib-typeahead behave like a dropdown select ?
I like the style of uib-typeahead when you use typeahead-min-length="0", and when you just click the text input you get all the possible options, so this kind of does what I want...
However, once you selected a first option, and you want to try another one, to get back the full list of options, you need to remove all the text from the input field first... whereas I would like to get it just by clicking the field.
So I would like to always get the full options list whatever text is already input... I know this is a bit against the idea of 'typeahead' if the tool doesn't care what you 'type ahead' ;)...
Another option would be to try and style a select with ng-options to look the same as uib-typeahead but I've read that it was not possible because the select dropdown list was a browser buitlin component. (is that correct?)
Any idea? Many thanks!

Custom content assist for default java editor in Eclipse

I'm currently trying to develop an Eclipse Plugin to support code replacement, like what the default content assist in Eclipse do. What I want to implement is something like "insert argument names automatically on method completion with visualized box around the argument" and I can "use the Tab key to navigate between the inserted names" and "while navigating, list of optional variables for current argument can be displayed and be chosen".
In short, it comes to two questions:
How to add the visualized box around the already existed variable or even Java keywords that need replacement? And at the meanwhile I can use Tab key to switch between these boxes.
How to display a list of candidates to select from when I trigger on the box?
By now I only figure out the extension point : org.eclipse.jdt.ui.javaCompletionProposalComputer may be useful, but I have no idea where to start at? Thanks in advance.
Oh, finally I've solved it myself...
For the 'box', it should be the LinkedModeModel, this class should work with LinkedPositionGroup and LinkedPosition to add mutiple boxes. And we should use LinkedModeUI to set it up.
For the content assistant, there's no need to use the extension point. There is a ProposalPosition class which extends LinkedPosition for you to add your proposals for the 'box' in its constructor. And we can simply use the CompletionProposal to construct a ICompletionProposal array as the argument of ProposalPosition's constructor.

Find CURRENTLY selected <option> with XPath

What's the correct XPath syntax to check if an option element is currently selected, or just to get the selected option element from a select element, on an open page with which the user, and JavaScript, may have interacted? Is this even possible with XPath, or does it lack the ability to look at DOM properties?
I can't find any documentation on this, and have (speculatively) tried:
//option[#selected=true]
//option[#selected="selected"]
//option[#selected]
but none of these work; they simply don't match any elements.
(In case it matters, I've tried this both using the $x function in the Chrome developer console, and using the find_elements_by_xpath method in Selenium for Python.)
Short answer: it's not possible.
Longer answer: XPath can look at HTML attributes, but it can't look at DOM properties. Selecting an <option> element in a <select> changes the selected property of the <option> to true, and also changes the value property of its parent <select> element, but it doesn't affect the attributes of either, so it is invisible to XPath.
To find <option> elements that have the selected attribute set, which is often how a page author might determine which option is initially selected, you can use //option[#selected]. But this does not find the currently selected <option>; changes that the user makes to the selection are invisible to XPath. There's no guarantee it will even find the initially selected option, since it's possible that the page author didn't put the selected attribute on any elements and either let the browser select the first option by default or had some JavaScript select the initial option via the selected property.
The multiple other answers here claiming that a selector like //option[#selected] can detect selection changes made by the user after the page loads are simply completely wrong.
Of course, if you're able to use CSS selectors instead of XPath selectors, then option:checked will do the job.
The problem could be the " (double quotes).
//select/option[#selected='selected'] - Will match the selected option, i am using this successfully.
//select/option[#selected='selected' and #value='specific value'] - Will only match the selected option if it has a 'specific value', i'm also using this.
If you are still having trouble, it could be an entirely different problem, perhaps there is no option node. I hope this helps.
I think we can use a knowledge from #Mark's answer and account that. Let's just find a node which HAS desired attribute:
tree.xpath('//select/option[#selected]/text()')[0].strip()
I tried "//option[#selected=''] and it has worked for me.
it is able to highlight the selected option within Page objects model.
I would try //option[#selected='true']
i.e. driver.findElements(By.xpath("//option[#selected='true']")).getText();

How to make tinymce styleselect to overwrite actual class with selected one

As i use styleselect combobox, i am able to apply many classes to one object simply by chosing each style from styleselect combobox, and I can turn off class only by chosing same class again. so all styles work like "checkboxes", and i wish to make from them "radiobuttons", i want mine tinymce to apply max 1 class to object, if parent has class, then split parent and aply class, for example
Some text here (i select "text" and set my_class2) and i wish to get result:
Some text here
and 2nd case, if i select all "Some text here" and aply my_class2 i wish to get result:
Some text here
(now result will be: Some text here
I hope it's clear now ;)
Best regards!
You might, if you don't mind meddling in their code. using the formatselect option, check out theme_advanced_blockformats in editor_template_src.js and add your tags with 'class=moshe' in them.. there could be only one tag (it replaces them), so you got your radio buttons :)
There is no standard way to insert checkboxes inside the tinymce UI. You should be able to make it work using checkboxes outside the editor and link to the function the style plugin uses.