unable to tab between BCX_TreeView and BCX_Button

Started by Quin, February 22, 2025, 09:50:27 AM

Previous topic - Next topic

Quin

I have this simple test code:

Gui "Test"

Enum
    ID_INFO_LABEL = 101
    ID_INFO_TREE
    ID_EXPORT_BUTTON
End Enum

Sub Formload
    Bcx_Mdialog(DlgProc, "Test", NULL, 0, 0, 640, 480)
End Sub

Begin Events
End Events

Begin Modal Dialog As DlgProc
    Static As Control InfoLabel, InfoTree, ExportButton
    Select Case Cbmsg
        Case WM_INITDIALOG
        InfoLabel = Bcx_Label("&Info", hWnd, ID_INFO_LABEL, 5, 5, 30, 5)
        InfoTree = Bcx_Treeview("", hWnd, ID_INFO_TREE, 5, 15, 250, 100)
        ExportButton = Bcx_Button("&Export...", hWnd, ID_EXPORT_BUTTON, 300, 30, 40, 40)
        Center hWnd
        SetFocus(InfoTree)
        Case WM_SETFOCUS
        Global As HWND hPrevFocus, hFocusedCtrl
        If hPrevFocus Then
            SetFocus(hPrevFocus)
            hPrevFocus = 0
        End If
        Exit Function
        Case WM_KILLFOCUS
        hFocusedCtrl = GetFocus()
        Exit Function
        Case WM_ACTIVATEAPP
        If Cbwparam = 0 Then
            hFocusedCtrl = GetFocus()
        Else
            If hFocusedCtrl Then
                hPrevFocus = hFocusedCtrl
                SetFocus(hFocusedCtrl)
                hFocusedCtrl = NULL
            End If
        End If
        Exit Function
    End Select
End Dialog

When I run it, I get landed no the tree view. If I press tab, I land on the button. hwoever, after that, i get stuck for some reason. I'm unable to tab or shift+tab from the button back on to the tree view, and the alt+i shortcut that should work to bring the tree view back into focus doesn't work, nor does pressing alt+e for export while focused on the tree view. What gives? I've also tried with a BCX_Form and get the same result.
-Quin.
GitHub

MrBcx

#1
BCX_Treeview does not (currently) come prepackaged with the WS_TABSTOP style, so add it yourself:

InfoTree = Bcx_Treeview("", hWnd, ID_INFO_TREE, 5, 15, 250, 100)
Modstyle(InfoTree, WS_TABSTOP)

Also, do yourself a favor and add the following to your event loop, so your app doesn't get stuck in memory when you close it.

CASE WM_QUIT, WM_CLOSE, WM_DESTROY
End

Quin

MrBcx,
I see, thanks! Would it be possible to add the WS_TABSTOP style by default? Is there a particular reason it isn't currently added?
Also thanks for the exiting tip, I ended up putting

PostQuitMessage(0)

after my dialog call, but I like your method better  8)
-Quin.
GitHub

MrBcx

Quote from: Quin on February 22, 2025, 04:16:15 PM
MrBcx,
I see, thanks! Would it be possible to add the WS_TABSTOP style by default? Is there a particular reason it isn't currently added?
Also thanks for the exiting tip, I ended up putting

PostQuitMessage(0)

after my dialog call, but I like your method better  8)

Quin,

I don't know why WS_TABSTOP was omitted but it will be included going forward starting with 8.2.5.

Quin

-Quin.
GitHub