Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard Navigation #3193

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
31e818b
Focus component search box with /
Venkata-Sai-Vishwanath-robo Jul 5, 2024
fe22d80
shortcuts for refreshing companion screen and resetting connection
Venkata-Sai-Vishwanath-robo Jul 5, 2024
a6cd6c5
Rename component with Alt + R
Venkata-Sai-Vishwanath-robo Jul 5, 2024
800c48c
Switch between design and blocks view
Venkata-Sai-Vishwanath-robo Jul 7, 2024
9c4646c
Navigation for the project explorer
Venkata-Sai-Vishwanath-robo Jul 7, 2024
e9af08a
Navigation for dropdowns
Venkata-Sai-Vishwanath-robo Jul 7, 2024
ec12849
css
Venkata-Sai-Vishwanath-robo Jul 7, 2024
64b4e99
Merge branch 'master' into keyboardNavigation
Venkata-Sai-Vishwanath-robo Jul 7, 2024
e8fc45a
shortcuts for blockly editor
Venkata-Sai-Vishwanath-robo Jul 7, 2024
b699190
Merge branch 'keyboardNavigation' of https://github.com/Venkata-Sai-V…
Venkata-Sai-Vishwanath-robo Jul 7, 2024
87eb4c5
checkbox text for screen readers
Venkata-Sai-Vishwanath-robo Jul 8, 2024
14501ed
Accessibility
Venkata-Sai-Vishwanath-robo Jul 8, 2024
d1f02f6
Tooltips and messages
Venkata-Sai-Vishwanath-robo Jul 8, 2024
b296f6c
better version of project explorer navigation
Venkata-Sai-Vishwanath-robo Jul 10, 2024
4e2a979
neo
Venkata-Sai-Vishwanath-robo Jul 14, 2024
d53b293
adding components using keyboard only
Venkata-Sai-Vishwanath-robo Jul 31, 2024
347b05b
focus SourceStructureExplorerItem on selection change.
Venkata-Sai-Vishwanath-robo Jul 31, 2024
79f7391
Focus trap for new folder and new project dialog box
Venkata-Sai-Vishwanath-robo Jul 31, 2024
6115d95
component adding
Venkata-Sai-Vishwanath-robo Aug 5, 2024
cd1c39e
property editors made keyboard accessible
Venkata-Sai-Vishwanath-robo Aug 8, 2024
18484a3
better focus visibility for checkboxes and ColorChoicePropertyEditor
Venkata-Sai-Vishwanath-robo Aug 8, 2024
f4cb850
Dropdown button maintaing focus, check box visibility and UI settings…
Venkata-Sai-Vishwanath-robo Aug 11, 2024
9a96f1a
Color choice property editor maintains focus after selection.
Venkata-Sai-Vishwanath-robo Aug 11, 2024
25d4f32
tree highlight and focus-trap in move projects dialog
Venkata-Sai-Vishwanath-robo Aug 14, 2024
e7e3b0f
Focus search text box with / (better code)
Venkata-Sai-Vishwanath-robo Aug 19, 2024
e5d131f
single line imports
Venkata-Sai-Vishwanath-robo Aug 19, 2024
dc22e43
fix : Constructor visibility
Venkata-Sai-Vishwanath-robo Aug 19, 2024
5963325
dialog boxes
Venkata-Sai-Vishwanath-robo Aug 23, 2024
b6f6330
updated isTextboxFocused method
Venkata-Sai-Vishwanath-robo Aug 23, 2024
2a52e64
Update: Component adding
Venkata-Sai-Vishwanath-robo Aug 25, 2024
4c98faf
Shortcuts Dialog box
Venkata-Sai-Vishwanath-robo Aug 25, 2024
5f40827
fix: shortcuts dialog
Venkata-Sai-Vishwanath-robo Aug 26, 2024
ce12f23
Component Moving
Venkata-Sai-Vishwanath-robo Aug 26, 2024
7ecfa20
tree highlighting upon click
Venkata-Sai-Vishwanath-robo Aug 26, 2024
ab4c3d4
Shortcuts dialog for neo
Venkata-Sai-Vishwanath-robo Aug 28, 2024
1ea4775
Shortcuts to focus the Viewer and Properties, using V and P
Venkata-Sai-Vishwanath-robo Sep 1, 2024
0244b78
fix: dropdown opens with no pre-selected item.
Venkata-Sai-Vishwanath-robo Sep 8, 2024
7e7cad3
chore: remove unused code.
Venkata-Sai-Vishwanath-robo Sep 8, 2024
080be5d
revert: remove unused code.
Venkata-Sai-Vishwanath-robo Sep 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -655,15 +655,15 @@ public interface OdeMessages extends Messages, AutogeneratedOdeMessages {
@Description("Message providing details about starting a USB connection.")
String usbMenuItem();

@DefaultMessage("Reset Connection")
@DefaultMessage("Reset Connection (Alt + Shift + R)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to revisit this choice, since Alt on Windows typically maps to Cmd on macOS, and Cmd + R will refresh the page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to revisit this choice, since Alt on Windows typically maps to Cmd on macOS, and Cmd + R will refresh the page.

Does't Ctrl usually map to Cmd on MacOS in GUI aps? I usually expect Alt to map to Option.

I realize that we have a Ctrl button, and that works as Ctrl for a lot of command line stuff. There's no consistent official mapping.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @ewpatton. I will look into these and fix them.
I will once go through the shortcuts in macOS and see for any more overlaps.
I still need to add code that adjusts the shortcut key messages based on whether the user is on Windows or macOS.
The community feedback is still pending, and I plan to complete it by the end of this week.

@Description("Reset all connections.")
String resetConnectionsMenuItem();

@DefaultMessage("Hard Reset")
@Description("Hard Reset the Emulator.")
String hardResetConnectionsMenuItem();

@DefaultMessage("Refresh Companion Screen")
@DefaultMessage("Refresh Companion Screen (Alt + R)")
@Description("Refresh the companion screen.")
String refreshCompanionMenuItem();

Expand Down Expand Up @@ -1254,7 +1254,7 @@ public interface OdeMessages extends Messages, AutogeneratedOdeMessages {
String blocksLoadFailure(String formName);

// Used in editor/youngandroid/palette/YoungAndroidPalettePanel.java
@DefaultMessage("Search Components...")
@DefaultMessage("Type / to search components")
@Description("Text shown in the component palette search box")
String searchComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.google.appinventor.client.editor.FileEditor;
import com.google.appinventor.client.editor.ProjectEditor;
import com.google.appinventor.client.editor.youngandroid.actions.SwitchScreenAction;
import com.google.appinventor.client.editor.youngandroid.actions.SwitchToBlocksEditorAction;
import com.google.appinventor.client.editor.youngandroid.actions.SwitchToFormEditorAction;
import com.google.appinventor.client.widgets.DropDownButton;
import com.google.appinventor.client.widgets.DropDownItem;
import com.google.appinventor.client.widgets.Toolbar;
Expand All @@ -21,9 +23,12 @@
import com.google.common.collect.Maps;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

import java.util.LinkedList;
import java.util.Map;
Expand Down Expand Up @@ -160,6 +165,7 @@ public DesignToolbar() {
// Gray out the Designer button and enable the blocks button
toggleEditor(false);
Ode.getInstance().getTopToolbar().updateFileMenuButtons(0);
toggleView();
}

public void bindUI() {
Expand Down Expand Up @@ -369,6 +375,22 @@ public void toggleEditor(boolean blocks) {
setButtonEnabled(WIDGET_NAME_REMOVEFORM, notOnScreen1);
}

public void toggleView() {
SwitchToBlocksEditorAction blockView = new SwitchToBlocksEditorAction();
SwitchToFormEditorAction designView = new SwitchToFormEditorAction();
RootPanel.get().addDomHandler(new KeyDownHandler() {
public void onKeyDown(KeyDownEvent event) {
if (event.isControlKeyDown() && event.isAltKeyDown()) {
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved
if (currentView == DesignToolbar.View.FORM) {
blockView.execute();
} else if (currentView == DesignToolbar.View.BLOCKS) {
designView.execute();
}
}
}
}, KeyDownEvent.getType());
}

public DesignProject getCurrentProject() {
return currentProject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,35 @@
package com.google.appinventor.client.editor.youngandroid.actions;

import com.google.appinventor.client.Ode;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Event;

public class RefreshCompanionAction implements Command {

private RefreshCompanionAction() {
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved
shortcutKeyHandler();
}

@Override
public void execute() {
if (Ode.getInstance().okToConnect()) {
Ode.getInstance().getTopToolbar().replUpdate();
}
}

private void shortcutKeyHandler() {
Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (event.getTypeInt() == Event.ONKEYDOWN && nativeEvent.getKeyCode() == KeyCodes.KEY_R
&& nativeEvent.getAltKey()) {
nativeEvent.preventDefault();
execute();
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,35 @@
package com.google.appinventor.client.editor.youngandroid.actions;

import com.google.appinventor.client.Ode;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Event;

public class ResetAction implements Command {

private ResetAction() {
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved
shortcutKeyHandler();
}

@Override
public void execute() {
if (Ode.getInstance().okToConnect()) {
Ode.getInstance().getTopToolbar().startRepl(false, false, false, false); // We are really stopping the repl here
}
}

private void shortcutKeyHandler() {
Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (event.getTypeInt() == Event.ONKEYDOWN && nativeEvent.getKeyCode() == KeyCodes.KEY_R
&& nativeEvent.getAltKey() && nativeEvent.getShiftKey()) {
execute();
nativeEvent.preventDefault();
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.google.appinventor.client.editor.youngandroid.palette;

import com.google.appinventor.client.ComponentsTranslation;
import com.google.appinventor.client.Ode;
import com.google.appinventor.client.editor.simple.SimpleComponentDatabase;
import com.google.appinventor.client.editor.simple.components.MockComponent;
import com.google.appinventor.client.editor.simple.components.utils.PropertiesUtil;
Expand All @@ -15,6 +16,7 @@
import com.google.appinventor.client.editor.simple.palette.SimpleComponentDescriptor;
import com.google.appinventor.client.editor.simple.palette.SimplePaletteItem;
import com.google.appinventor.client.editor.simple.palette.SimplePalettePanel;
import com.google.appinventor.client.editor.youngandroid.DesignToolbar;
import com.google.appinventor.client.editor.youngandroid.YaFormEditor;
import com.google.appinventor.client.explorer.project.ComponentDatabaseChangeListener;
import com.google.appinventor.client.wizards.ComponentImportWizard;
Expand All @@ -28,9 +30,12 @@
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.event.dom.client.KeyPressEvent;
Expand All @@ -44,11 +49,6 @@
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsType;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved

import static com.google.appinventor.client.Ode.MESSAGES;
Expand Down Expand Up @@ -82,6 +82,7 @@ public class YoungAndroidPalettePanel extends Composite implements SimplePalette
private final Map<String, String> translationMap;

private final TextBox searchText;
private boolean isSearchTextFocused = false;
private final VerticalPanel searchResults;
private JsArrayString arrayString = (JsArrayString) JsArrayString.createArray();
private String lastSearch = "";
Expand Down Expand Up @@ -183,6 +184,13 @@ public YoungAndroidPalettePanel(YaFormEditor editor) {
@Override
public void onBlur(BlurEvent event) {
doSearch();
isSearchTextFocused = false;
}
});
searchText.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
isSearchTextFocused = true;
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved
}
});
searchText.addChangeHandler(new ChangeHandler() {
Expand All @@ -192,6 +200,25 @@ public void onChange(ChangeEvent event) {
}
});

/* User presses the slash key, the search text box is focused */
RootPanel.get().addDomHandler(new KeyDownHandler() {
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved
@Override
public void onKeyDown(KeyDownEvent event) {
DesignToolbar designToolbar = Ode.getInstance().getDesignToolbar();
if (designToolbar.currentView == DesignToolbar.View.FORM) {
if (event.getNativeKeyCode() == 191 && !isSearchTextFocused) {
{
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved
event.preventDefault();
searchText.setFocus(true);
isSearchTextFocused = true;
}
}
} else {
isSearchTextFocused = false;
}
}
}, KeyDownEvent.getType());

panel.setSpacing(3);
panel.add(searchText);
panel.setWidth("100%");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public void onKeyDown(KeyDownEvent event) {
if (keyCode == KeyCodes.KEY_DELETE || keyCode == KeyCodes.KEY_BACKSPACE) {
event.preventDefault();
deleteItemFromTree();
} else if (event.isAltKeyDown() && keyCode == KeyCodes.KEY_N) {
Venkata-Sai-Vishwanath-robo marked this conversation as resolved.
Show resolved Hide resolved
event.preventDefault();
renameItem();
}
}
});
Expand All @@ -148,14 +151,7 @@ public void onKeyDown(KeyDownEvent event) {
renameButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
TreeItem treeItem = tree.getSelectedItem();
if (treeItem != null) {
Object userObject = treeItem.getUserObject();
if (userObject instanceof SourceStructureExplorerItem) {
SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
item.rename();
}
}
renameItem();
}
});
buttonPanel.add(renameButton);
Expand Down Expand Up @@ -195,6 +191,17 @@ private void deleteItemFromTree() {
}
}

private void renameItem() {
TreeItem treeItem = tree.getSelectedItem();
if (treeItem != null) {
Object userObject = treeItem.getUserObject();
if (userObject instanceof SourceStructureExplorerItem) {
SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
item.rename();
}
}
}

private void enableButtons(SourceStructureExplorerItem item) {
renameButton.setEnabled(item.canRename());
deleteButton.setEnabled(item.canDelete());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.google.appinventor.client.explorer.youngandroid.ProjectListItem;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
Expand All @@ -27,6 +29,7 @@
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.Label;

import java.util.ArrayList;
Expand Down Expand Up @@ -64,6 +67,7 @@ interface ProjectFolderUiBinder extends UiBinder<FlowPanel, ProjectFolder> { }
@UiField protected Label dateCreatedLabel;
@UiField protected CheckBox checkBox;
@UiField protected Icon expandButton;
@UiField protected FocusPanel expandbuttonFocusPanel;

public ProjectFolder(String name, long dateCreated, long dateModified, ProjectFolder parent) {
bindUI();
Expand Down Expand Up @@ -132,9 +136,19 @@ protected void toggleFolderSelection(ClickEvent e) {
fireSelectionChangeEvent();
}

@SuppressWarnings("unused")
@UiHandler("expandButton")
@UiHandler("expandbuttonFocusPanel")
protected void toggleExpandedState(ClickEvent e) {
toggleState();
}

@UiHandler("expandbuttonFocusPanel")
protected void toggleExpandedState(KeyDownEvent e) {
if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
toggleState();
}
}

private void toggleState() {
setSelected(false);
isExpanded = !isExpanded;
if (isExpanded) {
Expand All @@ -153,9 +167,9 @@ protected void toggleExpandedState(ClickEvent e) {
public void setSelected(boolean selected) {
checkBox.setValue(selected);
if (selected) {
container.addStyleName("ode-ProjectRowHighlighted");
container.addStyleName("ode-ProjectRow-Highlighted");
} else {
container.removeStyleName("ode-ProjectRowHighlighted");
container.removeStyleName("ode-ProjectRow-Highlighted");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
<g:FlowPanel styleName="ode-ProjectRowList">
<g:FlowPanel ui:field="container" styleName="ode-ProjectRow">
<g:CheckBox ui:field='checkBox' styleName='gwt-CheckBox'/>
<g:FlowPanel addStyleNames="ode-ProjectFieldSpan ode-ProjectNameLabel">
<ai:Icon icon='folder'/>
<ai:Icon ui:field='expandButton' icon='chevron_right'/>
<g:Label ui:field='nameLabel' styleName='gwt-Label ode-ProjectNameLabel'/>
</g:FlowPanel>
<g:FocusPanel ui:field='expandbuttonFocusPanel' styleName='ode-ExpandButtonFocusPanel'>
<g:FlowPanel addStyleNames="ode-ProjectFieldSpan ode-ProjectNameLabel">
<ai:Icon icon='folder'/>
<ai:Icon ui:field='expandButton' icon='chevron_right'/>
<g:Label ui:field='nameLabel' styleName='gwt-Label ode-ProjectNameLabel'/>
</g:FlowPanel>
</g:FocusPanel>
<g:Label ui:field='dateModifiedLabel' styleName='gwt-Label ode-ProjectFieldLabel ode-ProjectListDate'/>
<g:Label ui:field='dateCreatedLabel' styleName='gwt-Label ode-ProjectFieldLabel ode-ProjectListDate'/>
</g:FlowPanel>
Expand Down
Loading