Re: [WIN] PushButtons aren't depressed when hotkeys are used
- Posted by chris bensler <bensler at Mailops.Com> Jan 20, 2001
- 462 views
--==IMail_v5.0== >That's how Windows does it. I think the Mac and Amiga does it this way too. DOH!!! BLASTED windows! What's the deal with that! >Also, in Windows, focus does not shift to the button invoked via a hotkey. I wish that were true! If it were, I wouldn't be sitting here now waiting for a reply! I've managed to get it to work how I want, without shifting focus, by adding a setFocus () statement to the end of my routine. But because of that, I think the user will be confused as to whether or not they Button was actually invoked or not.. That's the reason I want the button to be depressed when they press the hotkey. I've attached my app, check it out, and tell me where I'm going wrong. All it does right now is allow the user to add/remove words to the list. But when you press ALT-A, it shifts focus to the button. Then the user has to use the mouse to get back to the SLE, or TAB through the controls. Also, I want to be able to Add a word to the list by pressing enter from the SLE. Can I do that? Chris Just realized, all my replies are going to individuals!! ________________________________________________________________ --==IMail_v5.0== without warning include win32lib.ew constant App="Word Scramble Puzzle Wizard", Ver="Ver 0.1a", CrLf={'\r','\n'} sequence FileName FileName="Untitled.wsp" function slice_seq(sequence TheSeq, integer ThePos) atom SeqLen SeqLen = length(TheSeq) if ThePos < 1 or ThePos > SeqLen then return TheSeq end if if ThePos = 1 then return TheSeq[2..SeqLen] elsif ThePos = SeqLen then return TheSeq[1..SeqLen-1] else return TheSeq[1..ThePos-1] & TheSeq[ThePos+1..SeqLen] end if end function -- INIT -- constant Main_Win=create(Window,"Word Scramble Wizard",0,Default,Default,220,140,or_all({WS_SYSMENU,WS_DLGFRAME})), -- Menus -- File_Menu=create(Menu,"&File",Main_Win,0,0,0,0,0), FNew=create(MenuItem,"&New",File_Menu,0,0,0,0,0), FOpen=create(MenuItem,"&Open",File_Menu,0,0,0,0,0), FClose=create(MenuItem,"&Close",File_Menu,0,0,0,0,0), FSep1=create(MenuItem,"-",File_Menu,0,0,0,0,0), FSave=create(MenuItem,"&Save",File_Menu,0,0,0,0,0), FSaveAs=create(MenuItem,"Save &As ...",File_Menu,0,0,0,0,0), FSep2=create(MenuItem,"-",File_Menu,0,0,0,0,0), FExit=create(MenuItem,"E&xit",File_Menu,0,0,0,0,0), Options_Menu=create(Menu,"&Options",Main_Win,0,0,0,0,0), OCList=create(MenuItem,"&Clear Word List",Options_Menu,0,0,0,0,0), OBuild=create(MenuItem,"&Build Puzzle",Options_Menu,0,0,0,0,0), Help_Menu=create(Menu,"&Help",Main_Win,0,0,0,0,0), HAbout=create(MenuItem,"&About ...",Help_Menu,0,0,0,0,0), -- Controls -- Word_Group=create(Group,"",Main_Win,-2,-6,218,104,1), WGAdd_But=create(PushButton,"&Add Word",Word_Group,8,15,95,22,0), WGRemove_But=create(PushButton,"&Remove Word",Word_Group,115,15,95,22,0), WGWords_Combo=create(SortedCombo,"",Word_Group,8,45,202,40,0), WGBuild_But=create(PushButton,"&Build Puzzle",Word_Group,8,75,202,22,0) setText(Main_Win,FileName & " - " & App) setEnable(FClose,0) setEnable(FSave,0) setEnable(FSaveAs,0) addItem(WGWords_Combo," - WORD LIST - ") sequence WORD_LIST WORD_LIST ={" - WORD LIST - "} atom NumWords NumWords =1 atom ListSize ListSize =40 -- CONTROL EVENTS -- -- Add Button -- procedure Add_Word() sequence TheWord TheWord = getText(WGWords_Combo) for i = 1 to length(TheWord) do if TheWord[i] <'A' or TheWord[i] >'z' or TheWord[i] >'z' and TheWord[i] <'a' then TheWord = "" exit end if end for if not find(TheWord,WORD_LIST) and not equal(TheWord,"") and not equal(TheWord," - WORD LIST - ") then WORD_LIST &= {TheWord} NumWords = length(WORD_LIST) ListSize = NumWords*20+20 if ListSize > 200 then ListSize = 200 end if setSize(WGWords_Combo,202,ListSize) addItem(WGWords_Combo,WORD_LIST[NumWords]) setText(WGWords_Combo,"") -- setFocus(WGWords_Combo) end if end procedure onClick[ WGAdd_But ] = routine_id("Add_Word") procedure onKDown_WGWords_Combo(integer KeyCode, integer Mask) if KeyCode = 13 then Add_Word() end if end procedure onKeyDown[ WGWords_Combo ] = routine_id("onKDown_WGWords_Combo") procedure onKPress_WGAdd_But(integer KeyCode,integer Mask) if KeyCode = 13 then Add_Word() elsif KeyCode='a' or KeyCode='A' and Mask=AltMask then Add_Word() setFocus(WGWords_Combo) end if end procedure onKeyPress[ WGAdd_But ] = routine_id("onKPress_WGAdd_But") -- Remove Button -- procedure Remove_Word() sequence TheWord atom TheIndex if NumWords !=0 then TheIndex = getIndex(WGWords_Combo) TheWord = getItem(WGWords_Combo,getIndex(WGWords_Combo)) if TheIndex != 1 then -- not equal(TheWord," - WORD LIST - ") then WORD_LIST = slice_seq(WORD_LIST,find(TheWord,WORD_LIST)) NumWords = length(WORD_LIST) ListSize = NumWords*20+20 if ListSize<40 then ListSize=40 elsif ListSize>200 then ListSize=200 end if if deleteItem(WGWords_Combo,getIndex(WGWords_Combo)) then end if setSize(WGWords_Combo,202,ListSize) setText(WGWords_Combo,"") end if end if end procedure onClick[ WGRemove_But ] = routine_id("Remove_Word") procedure onKPress_WGRemove_But(integer KeyCode, integer Mask) if KeyCode = 13 then Remove_Word() end if setFocus(WGWords_Combo) end procedure onKeyPress[ WGRemove_But ] = routine_id("onKPress_WGRemove_But") -- Build Button -- procedure onClick_WGBuild_But() end procedure onClick[ WGBuild_But ] = routine_id("onClick_WGBuild_But") -- MENU EVENTS -- -- File menu -- procedure onMenu_FNew() end procedure onClick[ FNew ] = routine_id("onMenu_FNew") procedure onMenu_FOpen() end procedure onClick[ FOpen ] = routine_id("onMenu_FOpen") procedure onMenu_FClose() end procedure onClick[ FClose ] = routine_id("onMenu_FClose") procedure onMenu_FSave() end procedure onClick[ FSave ] = routine_id("onMenu_FSave") procedure onMenu_FSaveAs() end procedure onClick[ FSaveAs ] = routine_id("onMenu_FSaveAs") procedure onMenu_FExit() closeWindow(Main_Win) end procedure onClick[ FExit ] = routine_id("onMenu_FExit") -- Options Menu -- procedure onMenu_OCList() for i = getCount(WGWords_Combo) to 1 by -1 do if deleteItem(WGWords_Combo,i) then end if end for setSize(WGWords_Combo,202,40) end procedure onClick[ OCList ] = routine_id("onMenu_OCList") -- Help Menu -- procedure onMenu_HAbout() integer result result = message_box( CrLf & "Word Scramble Puzzle Creator" & CrLf & " created by ..." & CrLf & " Chris Bensler" & CrLf & CrLf & " using ..." & CrLf & " David Cuny's win32lib v0.45a" & CrLf,-- text "About... " & App & " " & Ver, -- title MB_ICONINFORMATION+MB_TASKMODAL ) -- icon end procedure onClick[ HAbout ] = routine_id( "onMenu_HAbout" ) -- MAIN WINDOW EVENTS -- -- DO IT! -- WinMain( Main_Win, Normal ) --==IMail_v5.0==--