I have a list box on a different tab that I am changing with the press on of space bar once certain conditions are met (checkbox pressed and the tab panel locked). I am also using the left and right arrow keys to move between the listbox. the left right arrow key work perfectly.
I have some odd behaviour with crb(32), space bar press, only working up until row 20 though the key press is not dependent the row value. I want this to move to the next row, just like the right arrow does (assuming a checkbox is ticked - that is disabled by this point)
I’m not 100% sure If I have isolated when the condition for it to stop working. but It seem as though the space bar recognition stops returning true once the row has gone beyond 20 (and then remains this way for the remainder of the application). The only way I can get it to register the space bar again is to click the tab panel again and then it will work once, until you do that again. The arrow keys keep working fine. Can anyone make sense of that?
I would have thought maybe for some reason it wasn’t getting passed the first if statement, but it cannot be because the arrow keys still work regardless.
i have tried chr and chrb - I am only after a simple key stroke to be detected - nothing fancy. the SetFocusTimer is there to focus on an invisible object so then the key doesn’t select something that could be triggered by the space bar.
This is on keydown event for whole window.
if TabPanel1.SelectedPanelIndex = 4 And LockSegment.SelectedSegmentIndex = 1 then
if Key = CHRB(28) then // left key
SelectUpLeft
SetFocusTimer.RunMode = timer.RunModes.Single
return true
elseif key = CHRB(29) then
SelectDownRight
SetFocusTimer.RunMode = timer.RunModes.Single
return true
elseif key = CHRB(30) or key = CHRB(31) then //up/down arrows
SetFocusTimer.RunMode = timer.RunModes.Single
return true
elseif Key = Chr(32) then //space bar - PROBLEM
if SpaceKeyCheckBox.Value = true then
SelectDownRight
end if
SetFocusTimer.RunMode = timer.RunModes.Single
return true
elseif key = Chr(3) or key = Chr(13) then //enter key pressed - resend midi data
If Valuebox.SelectedRowIndex = -1 then /// check for deselect
//do nothing
else
MidiSendSongSelect(ValueBox.SelectedRowIndex)
end if
SetFocusTimer.RunMode = timer.RunModes.Single
return true
end if
end if
Thanks
My feeling:
I used
Select Case Key
Case <key_case>
etc.
Also, I do not know why you use a Timer.
Chr() vs Chr(B): I do not have an opinion, but I am curious to know why …
Thanks that is neater code, but my main problem still exists.
If I recall correctly the timer (10ms) was needed for the set focus to work after a space bar press, if it was declared straight after without a pause it would not work. I think It was fine for the arrow keys. I don’t know why that is either. Obviously the space key usually acts as an enter for what ever is focused, that’s the only difference I can think of.
Chr/chrb I was just saying I had tried both. I am not sure what the difference is because I cannot find anything on it in the documentation.
if TabPanel1.SelectedPanelIndex = 4 And LockSegment.SelectedSegmentIndex = 1 then
Select Case Key
case CHRB(28)
SelectUpLeft
SetFocusTimer.RunMode = timer.RunModes.Single
return true
case CHRB(29)
SelectDownRight
SetFocusTimer.RunMode = timer.RunModes.Single
return true
case CHRB(30), CHRB(31) //up/down arrows
SetFocusTimer.RunMode = timer.RunModes.Single
return true
case Chr(32) //space bar PROBLEM
if SpaceKeyCheckBox.Value = true then
SelectDownRight
end if
SetFocusTimer.RunMode = timer.RunModes.Single
return true
Case Chr(3), Chr(13)
If Valuebox.SelectedRowIndex = -1 then /// check for deselect
//do nothing
else
MidiSendSongSelect(ValueBox.SelectedRowIndex)
end if
SetFocusTimer.RunMode = timer.RunModes.Single
return true
end select
end if
I found an example using Chr() in the DesktopListBox documentation there:
https://documentation.xojo.com/api/user_interface/desktop/desktoplistbox.html#desktoplistbox-headerat
Documentation about: Chr
But I do not have advice for your trouble. Sorry.
I just recreated this from scratch in a new project and its working fine! So I don’t know what my problem is in my main project. Very odd, thought my main project is a lot more complicated with more columns and checkboxes and tab panels. I don’t see how that would affect the space bar being recognised.
I realise not it doesn’t seem to be linked to this script I gave.
it still happens when tab to focus on my button to move to the next row and use the space bar to select/enter on it (when out of the lock mode) and then it stops at row 20, (but clicking is fine),
And then the space bar completely locks up then on after that… so no wonder it won’t trigger the code. The only way to renege is to click on the tab panel, but it will only work once then lock up again.
Never mind, I solved it by changing the setfocus to the tabpanel1 rather than random free check box (set for this purpose), which is neater anyway. Not sure when this solved it or why it glitched out at row 20 but it seem there’s something responding differently with the setfocus with the space bar compared to the other keys perhaps because it is also an enter button for whatever the current focus is.
Checkboxes respond to spacebar automatically, it toggles them on and off.