Author |
Topic: Button feature discovered? (Read 663 times) |
|
GeoffG
New Member
member is offline


Posts: 2
|
 |
Button feature discovered?
« Thread started on: Feb 18th, 2015, 12:31pm » |
|
I wanted to save creating bitmaps for a toolbar since the buttons would only hold numbers. Using WINLIB5, I created a row of buttons but found that after using these, keyboard shortcuts stopped working. A test program displaying this is attached:
Code: REM Test Program for Button 'feature'
REM Click mouse in window then use ^C to copy coords
REM these may then be pasted into a text editor.
REM Menu may be accessed (play tones) and copy still works.
REM After using buttons (different tones) copy has old coords.
REM If window covered by another and then revealed,
REM copy begins to work again.
INSTALL @lib$+"WINLIB5" : REM Buttons
AM$ = "AppendMenu"
SYS "CreatePopupMenu" TO hpop1%
SYS AM$, hpop1%, 0, 1, "&Go"
SYS AM$, hpop1%, 0, 2, "&Stop"
SYS "CreateMenu" TO H%
SYS AM$, H%, 16, hpop1%, "&Mode "
SYS "SetMenu",@hwnd%,H%
SYS "DrawMenuBar",@hwnd%
DIM hb%(4)
FOR I%=0 TO 3
hb%(I%)=FN_button(STR$I%,4+I%*40,0,36,36,100+I%,0)
NEXT
ON MOUSE PROCmouse(@wparam%,@lparam%) : RETURN
ON SYS PROCmenu(@wparam%,@lparam%) : RETURN
OFF
REPEAT
key% = INKEY(1)
CASE key% OF
WHEN 3 : PROCcopy
ENDCASE
UNTIL FALSE
END
DEF PROCmenu(wp%,lp%)
CASE wp% OF
WHEN 1 : SOUND 1,-15,136,5
WHEN 2 : SOUND 1,-15,88,5
WHEN 100,101,102,103,104 : PROCselect(wp%-100)
ENDCASE
ENDPROC
DEF PROCmouse(wp%,lp%)
X%=(lp% AND &FFFF)*2 - @vdu.o.x%
Y%=(@vdu%!212-1-(lp% >>> 16))*2 - @vdu.o.y%
ENDPROC
DEF PROCselect(n%)
SOUND 1,-10,n%*4+148,2
ENDPROC
DEF PROCcopy
LOCAL R%,C%,t$
REM copy grid to clipboard
t$ = "X = "+STR$X%+", Y = "+STR$Y%
SYS "GlobalAlloc", &2000, LEN(t$)+1 TO hdata%
SYS "GlobalLock", hdata% TO tmp%
$$tmp% = t$
SYS "GlobalUnlock", hdata%
SYS "OpenClipboard", @hwnd%
SYS "EmptyClipboard"
SYS "SetClipboardData", 1, hdata%
SYS "CloseClipboard"
ENDPROC
I would be interested to hear what I have done wrong or what the problem is. Replacing the DIY toolbar with a 'proper' one corrects the issue but means I have a series of bitmaps to deal with.
Geoff
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Button feature discovered?
« Reply #1 on: Feb 18th, 2015, 2:17pm » |
|
on Feb 18th, 2015, 12:31pm, GeoffG wrote:I created a row of buttons but found that after using these, keyboard shortcuts stopped working. |
|
Is this not the old input focus chestnut? When you click on a button the input focus is moved to that button (which is a window in its own right, like all controls). So, unless you make a point of transferring the focus back to the 'main window', any subsequent keyboard input will be sent to the button and will never reach (for example) BASIC's INKEY function.
This is a well-known issue, which basically arises from trying to mix two quite different styles of interface: a Windows GUI control (like a button) and BBC BASIC's emulated 1980's-vintage keyboard input and graphics output.
The best solution is to avoid mixing two dissimilar user interfaces (i.e. either do everything using Windows controls or everything via traditional BASIC input/output). But if you want to continue to use the 'mixed environment' the straightforward workaround is to send the input focus back to the mainwin after a button is pressed:
Code: DEF PROCselect(n%)
SOUND 1,-10,n%*4+148,2
PROC_setfocus(@hwnd%)
ENDPROC Quote:Replacing the DIY toolbar with a 'proper' one corrects the issue but means I have a series of bitmaps to deal with. |
|
You only need a single bitmap (conventionally one provides all the button images as a 'strip', such as the WIDGETS.BMP file supplied with BB4W in the EXAMPLES\WINDOWS folder). As you want the button images to be digits, you could easily create that bitmap at runtime in your own program.
Richard.
|
|
Logged
|
|
|
|
GeoffG
New Member
member is offline


Posts: 2
|
 |
Re: Button feature discovered?
« Reply #2 on: Feb 18th, 2015, 3:06pm » |
|
Thanks Richard, I had thought that it was an input focus problem but I had been unable to tie it down ... the focus always appeared to be in the main window. However, it does seem to sort it out (when I originally tried a similar solution I crashed BB4W ... don't know why). I think I'll stick with a proper toolbar and try your 'generating a bitmap on the fly' solution ... much nicer. Thanks again, Geoff
|
|
Logged
|
|
|
|
|