On 9 Sep 2009, at 14:31, Dilwyn Jones wrote:
I wonder if anyone can help me with a feature of the Easyptr 4
MCALLT function I stumbled across when trying to write a little
program using an application window with no menu and a simple MAWBAR
installed.
It all works well enough using the mouse, but if I press a key in
the keyboard, e.g. a cursor arrow key, I get a different result.
The menu has one loose item (ESC, loose item -1) and just a single
application window number 1. Any example menu should work as long as
the application window is less than 200x200
10 MDRAW #0,win1_qform_testmenu_men
15 MAWBAR #0,1,200,200
20 REPeat program
30 time% = 250 : event% = 255 : ch% = 0
40 num = MCALLT(#ch%,event%,time%)
50 SELect ON num
60 =-1 : EXIT program : REMark Esc loose item
70 =REMAINDER
80 MWINDOW #0,1 : CLS #0 : INK #0,0 : OVER #0,0 : PRINT
#0,num,HEX$(num,32)
90 END SELect
100 END REPeat program
110 MCLEAR #0
The MAWBAR in line 15 just sets up pan and scroll bars for an area
(size not significant as long as larger than the application window,
otherwise pan and scroll bars not needed of course)
Line 30 time% makes MCALLT time out after 5 seconds (time, for
bubble help, not used here)
event% just makes sure it returns after all window events (sleep,
etc, again not significant here)
Line 80 just shows the value returned by MCALLT into 'num' and shows
it in decimal and in hex to make it easier to look at what's
happening.
If you move the mouse inside the application window, it retruns 0000
0001 as you'd expect (application window number).
If, however, you move the pointer using the cursor arrow keys on the
keyboard while the pointer is inside the application window instead
it returns $00C00001 etc, with the upper 4 hex digits containing the
ASCII code of the key pressed (any key, not just cursor keys) not
just the app window number as you'd get using the mouse.
It looks like there is an "undocumented" facility where MCALLT (not
checked MCALL) can tell you if the mouse or keyboard did the last
operationin in an app window with no menu and scroll bars??? Maybe I
misunderstand the feature???
Can anyone else confirm this before I pester Marcel about it, I
think I'm already on his blacklist about Easyptr before I make
things even worse :o)
I can't say what MCALLT will do but it will be, no doubt much the same
as WRPTRT in TurboPTR. This function reads the pointer, with timeout,
and returns appropriate information. This can be quite complicated and
some of it, relating to pan and scroll bars, does not seem to be in
Jochen's QPTR manual. The definitions of the functions WRPTR and
WRPTRT are:
WRPTR (wwd [,adr]) and
WRPTRT(wwd, timeout, events [,adr])
Both these functions read the pointer and return with information in
a long word k. "wwd" is the address of the working definition.
WRPTR returns after a loose item or menu item in an application
window has been hit.
WRPTRT is the same as WRPTR but in addition it has a timeout facility
("timeout"). It also has the facility to specify, in "events", which
job events it will return on.
The definition of the long word k is:
Byte Byte Word
pad code Item number
Bit 0 of pad is 1 for a "DO" and 0 for a "HIT". The other bits of pad
are undefined.
Code is -128 to signify an error
-4 to signal timeout
-3 to signify pan/scroll
-2 to signify an "event"
-1 to signify a "loose item"
the number of an application window
otherwise
Item number is the value of the event or pan/scroll, or the item
number of the loose item or of the application window menu.
For an application window, number -1 means "cancel" and -2 means
"do". Other numbers are the numbers of the menu items
The "value" of an event is:
1 for do (ENTER)
2 for quit
4 for help
8 for move
16 for resize
32 for sleep
64 for wake
For a pan/scroll the "hit" position on a scroll bar is placed in the
location pointed to by the parameter "adr".
The "value" of a pan/scroll is:
256*j + n
where n is the section of the bar to be panned/scrolled and j is as
follows:
Space/Hit Enter/Do Where
$70 $74 Top arrows
$71 $75 Bottom arrows
$72 $76 Left arrows
$73 $77 Right arrows
$78 $7C Scroll bar
$7A $7E Pan bar
The long word containing the "hit" position has "pos" in its top
word and "len" in its bottom word.
I hope that this will be of some help!
George
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm