How to change disabled color in MRTK Interactable buttons correctly? - unity3d

I am working to an application with unity3D and MRTK package for hololens2 and I am trying to change the color of a toggle when it is disabled.
The toggle has an Interactable script on it with many profiles, one of them has two themes for the selected state that are "InteractableActivateTheme" and "Interactable color children theme".
I used successfully the latter to change color of the toggle when selected using the theme field "Pressed" and "Default", but I am not able to use the "Disabled" field in any case.
Screenshot of the profile I am talking about
I disable the toggle by code setting the state to disabled in this way:
PlaceToggle.SetState(InteractableStates.InteractableStateEnum.Disabled, true);
PlaceToggle.enabled = true;
The toggle disables itself but the color remains red has set in the "Default" State Properties of the "InteractableColorChildrenTheme".
I also tried to change the color by code like this, but I had no result:
var activeThemes = PlaceToggle.ActiveThemes;
foreach (InteractableThemeBase itb in activeThemes)
{
if (itb is InteractableColorChildrenTheme)
{
Debug.Log(" changing state property");
var property = itb.StateProperties;
oldColor = itb.StateProperties[0].Values[0].Color;
itb.StateProperties[0].Values[0].Color = Color.gray;
}
}
Any idea on how could I understand what it is happening and why it is not working??
Thanks you all

Please try the following code to disable your button:
buttonInteractable = this.GetComponent<Interactable>();
buttonInteractable.IsEnabled = false;
Verified in MRTK2.7 & Unity 2019.4.22.

Related

Vaadin-Grid: Select all check box does not work in the UI

Problem:
I have a grid with lazy loading and therefore my data is not in memory.
To show the check box to select/deselct all i used this Question.
My code looks like this:
Grid<CustomClass> grid;
...
// set selection mode
grid.setSelectionMode(SelectionMode.MULTI);
// make select all check box visible
GridSelectionModel<CustomClass> selectionModel = grid.getSelectionModel();
((GridMultiSelectionModel<CustomClass>) selectionModel)
.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility.VISIBLE);
The Problem is, that the check box does not work in the UI as you can see:
If i log the selected items with the following code the check box works as expected
grid.addSelectionListener(l -> {
log.info("selected: " + l.getAllSelectedItems().size());
});
Question:
What can i do that the check box also works in the UI?
The Solution i found that the checkoxes are updated in the UI is to add dataPovider.refreshAll() in the listener.
Code of the Solution:
grid.addSelectionListener(l -> {
...
dataPovider.refreshAll();
...
});

Enterprise Architect: Hide only "top" labels of connectors programmatically

I want to hide the "top" part of all connector labels of a diagram. For this, I tried to set up a script, but it currently hides ALL labels (also the "bottom" labels which I want to preserve):
// Get a reference to the current diagram
var currentDiagram as EA.Diagram;
currentDiagram = Repository.GetCurrentDiagram();
if (currentDiagram != null)
{
for (var i = 0; i < currentDiagram.DiagramLinks.Count; i++)
{
var currentDiagramLink as EA.DiagramLink;
currentDiagramLink = currentDiagram.DiagramLinks.GetAt(i);
currentDiagramLink.Geometry = currentDiagramLink.Geometry
.replace(/HDN=0/g, "HDN=1")
.replace(/LLT=;/, "LLT=HDN=1;")
.replace(/LRT=;/, "LRT=HDN=1;");
if (!currentDiagramLink.Update())
{
Session.Output(currentDiagramLink.GetLastError());
}
}
}
When I hide only the top labels manually (context menu of a connector/Visibility/Set Label Visibility), the Geometry property of the DiagramLinks remains unchanged, so I guess the detailed label visibility information must be contained somewhere else in the model.
Does anyone know how to change my script?
Thanks in advance!
EDIT:
The dialog for editing the detailed label visibility looks as follows:
My goal is unchecking the "top label" checkboxes programmatically.
In the Geometry attribute you will find a partial string like
LLT=CX=36:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:DIR=0:ROT=0;
So in between LLT and the next semi-colon you need to locate the HDN=0 and replace that with HDN=1. A simple global change like above wont work. You need a wild card like in the regex LLT=([^;]+); to work correctly.

Changing colours for button which have got a focus

I use DotNetBar controls. I can change colours for buttons with:
Office2007ColorTable table = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
Office2007ButtonItemColorTable bt = table.ButtonItemColors[6];
bt.Default.Background = new LinearGradientColorTable(Color.White);
bt.MouseOver.Background = new LinearGradientColorTable(Color.Green);
Unfortunate I cannot find how I can change colour for a focused button.
Is it possible?

Why doesn't marker.dragging.disable() work?

The following code receives an error on the lines for enabling and disabling the marker dragging ("Unable to get property 'disable' of undefined or null reference"). The markers show up on the map just fine and are draggable as the creation line indicates. Placing an alert in place of the enable line produces a proper object so I believe the marker is defined. Is there something I need to do to enable the IHandler interface? Or am I missing something else?
var marker = L.marker(L.latLng(lat,lon), {icon:myIcon, draggable:'true'})
.bindLabel(name, {noHide: true,direction: 'right'});
marker._myId = name;
if (mode === 0) {
marker.dragging.enable();
} else {
marker.dragging.disable();
}
I had a similar problem today (perhaps the same one) it was due to a bug in leaflet (see leaflet issue #2578) where changing the icon of a marker invalidates any drag handling set on that marker. This makes any calls to marker.dragging.disable() fail.
The fix hasn't made it into leaflets master at time of writing. A workaround is to change the icon after updating the draggable status if possible.
marker.dragging.disable();
marker.setIcon(marker_icon);
Use the following code to make an object draggable. Set elementToDrag to the object you wish to make draggable, which is in your case: "marker"
var draggable = new L.Draggable(elementToDrag);
draggable.enable();
To disable dragging, use the following code:
draggable.disable()
A class for making DOM elements draggable (including touch support).
Used internally for map and marker dragging. Only works for elements
that were positioned with DomUtil#setPosition
leaflet: Draggable
If you wish to only disable the drag option of a marker, then you can use the following code (where "marker" is the name of your marker object):
marker.dragging.disable();
marker.dragging.enable();
I haven't found an answer but my workaround was this:
var temp;
if (mode === 0) {
temp = true;
} else {
temp = false;
}
var marker = L.marker(L.latLng(lat,lon), {icon:myIcon, draggable:temp})
.bindLabel(name, {noHide: true,direction: 'right'});
marker._myId = name;
Fortunately I change my icon when it is draggable.

While switching to windows classic theme combo contribution item shirnks

I do have a problem with IToolbarManager. I have added a combo & spinner ot toolbar of a view like this
IToolbarManager mgr = getViewSite().getActionBars().getToolBarManager();
mgr.add(spinnerCntrAction);
spinnerCntrAction = new ControContribution(){
public Control createControl(){
//Creates composite
//Create a spinner and add that to composite
//return composite
}
};
In windows XP/Vista themes this spinner is shown correctly. But when program is run under windows classic theme , the spinner is shrinked and not shown correctly.
Is this a known problem ? Do you know any workaround/patch for this ?
Thanks
Jijoy
This is a bug in SWT. See http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg44671.html
Here is a workaround:
mgr.add(new DummyAction());
private static class DummyAction extends Action {
DummyAction() {
setEnabled(false);
setText(" ");
}
}
...
mgr.add(spinnerCntrAction);
This will cause the toolbar manager to make all control contributions the same size as the Action, so adjust the number of spaces in the Action text to get the desired result.