Commit 9615b7a7 authored by Matthew Coufal's avatar Matthew Coufal Committed by Susan Rati Lane

Enable multiple component selection using shift key presses (#1891)

* Enable multiple component selection using shift key presses
* Add highlight to select components and show number of components selected
* Make selected component properties default when there is no full intersection
* Allow unselection of already selected components
parent bfdb5ac2
......@@ -10,6 +10,7 @@ import static com.google.appinventor.client.Ode.MESSAGES;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import com.google.appinventor.client.editor.simple.SimpleEditor;
......@@ -915,14 +916,25 @@ public final class MockForm extends MockContainer {
if (newSelectedComponent == null) {
throw new IllegalArgumentException("at least one component must always be selected");
}
if (newSelectedComponent == oldSelectedComponent) {
YaFormEditor formEditor = (YaFormEditor) editor;
boolean shouldSelectMultipleComponents = formEditor.getShouldSelectMultipleComponents();
List<MockComponent> selectedComponents = formEditor.getSelectedComponents();
if (shouldSelectMultipleComponents && selectedComponents.size() > 1 && formEditor.isSelectedComponent(newSelectedComponent)) {
int index = selectedComponents.indexOf(newSelectedComponent);
selectedComponent = selectedComponents.get((index == 0) ? 1 : index - 1);
newSelectedComponent.onSelectedChange(false);
return;
}
selectedComponent = newSelectedComponent;
Map<String, MockComponent> componentsMap = formEditor.getComponents();
if (oldSelectedComponent != null) { // Can be null initially
oldSelectedComponent.onSelectedChange(false);
if (oldSelectedComponent != null && !shouldSelectMultipleComponents) { // Can be null initially
for (MockComponent component : componentsMap.values()) {
if (component.getName() != selectedComponent.getName()) {
component.onSelectedChange(false);
}
}
}
newSelectedComponent.onSelectedChange(true);
}
......
......@@ -4,7 +4,6 @@
// http://www.apache.org/licenses/LICENSE-2.0
package com.google.appinventor.client.editor.simple.palette;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.TouchEndEvent;
......
......@@ -146,7 +146,7 @@ public final class EditableProperty extends Property {
*
* @return property caption
*/
String getCaption() {
public String getCaption() {
return caption;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment