Skip to content

draft PR: search functionality in custom shortcuts panel #53

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 50 additions & 6 deletions src/components/DialogBox/CustomShortcut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
>
<v-icon>mdi-close</v-icon>
</v-btn>
<div id="customShortcutDialog" title="Keybinding Preference">
<v-text-field label="Search Command" v-model="search"></v-text-field>
<div v-if="search && searchCommand().length" id="customShortcutDialog" title="Keybinding Preference">
<!-- Edit Panel -->
<div id="edit" tabindex="0" @keydown="updateEdit($event)">
<span style="font-size: 14px">
Expand All @@ -37,13 +38,47 @@
>
<!-- Elements -->
<div
v-for="(keyOption, index) in keyOptions"
v-for="(keyOption, index) in searchCommand()"
:key="index"
>
<span id="edit-icon"></span>
<div>
<span id="command">{{ keyOption[0] }}</span>
<span id="keyword"></span>
<span id="keyword">{{keyOption[1]}}</span>
</div>
</div>
</div>
</div>
<div v-if="!search" id="customShortcutDialog" title="Keybinding Preference">
<!-- Edit Panel -->
<div id="edit" tabindex="0" @keydown="updateEdit($event)">
<span style="font-size: 14px">
Press Desire Key Combination & press Enter or press
ESC to cancel.
</span>
<div id="pressedKeys"></div>
<div id="warning"></div>
</div>
<!-- Heading -->
<div id="heading">
<span>Command</span>
<span>Keymapping</span>
</div>
<!-- Markup -->
<div
id="preference"
class="customScroll"
@click="updatePreference($event)"
>
<!-- Elements -->
<div
v-for="(keyOption, index) in keyOptions"
:key="index"
>
<span id="edit-icon"></span>
<div>
<span id="command">{{ keyOption[0] }}</span>
<span id="keyword">{{keyOption[1]}}</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -82,6 +117,8 @@ import { onMounted, onUpdated, ref } from '@vue/runtime-core'
const SimulatorState = useState()
const keyOptions = ref([])
const targetPref = ref(null)
const search = ref('');


onMounted(() => {
SimulatorState.dialogBox.customshortcut_dialog = false
Expand All @@ -95,6 +132,13 @@ onUpdated(() => {
} else setDefault()
})

const searchCommand=()=>{
if(!search.value) return [];
const searchResult = keyOptions.value.filter((target)=>{
return target[0].toLowerCase().includes(search.value.toLowerCase());
})
return searchResult;
}
function updatePreference(e) {
$('#pressedKeys').text('')
$('#warning').text('')
Expand Down Expand Up @@ -154,11 +198,11 @@ function updateEdit(e) {
$('#pressedKeys').text(currentKey)
}
if (
($('#pressedKeys').text().split(' + ').length === 2 &&
($('#pressedKeys').text().split(' + ').length === 2 &&
['Ctrl', 'Meta'].includes(
$('#pressedKeys').text().split(' + ')[1]
$('#pressedKeys').text().split(' + ')[1]
)) ||
($('#pressedKeys').text().split(' + ')[0] === 'Alt' &&
($('#pressedKeys').text().split(' + ')[0] === 'Alt' &&
$('#pressedKeys').text().split(' + ')[1] === 'Shift')
) {
$('#pressedKeys').text(
Expand Down
1 change: 1 addition & 0 deletions src/styles/css/shortcut.panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
}

#customShortcutDialog {
width: 600px;
align-items: center;
color: white;
flex-direction: column;
Expand Down