Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
tips:revmedia:v4i5a8 [2023/11/27 14:08] – bshumsky | tips:revmedia:v4i5a8 [2024/06/19 20:20] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Version 3 Technical Highlights - Add_Buttons===== | ||
+ | ^Published By^Date^Version^Knowledge Level^Keywords^ | ||
+ | |Sprezzatura Ltd|01 OCT 1992|3.0+|EXPERT|ADD_BUTTONS, | ||
+ | |||
+ | The program on the following pages uses this extended functionality to put | ||
+ | buttons on the screen in an AREV window as in the illustration below. When | ||
+ | the buttons are pointed at and clicked with the mouse the buttons give the | ||
+ | illusion of being pressed into the screen and provide an audible click. | ||
+ | Setting up the buttons is simple a case of putting five parameters per | ||
+ | button into Register(5) of the window (see below), the parameters being | ||
+ | Label, X, Y, Code Command as shown below. Then add a call to ADD_BNS | ||
+ | passing PRE_INIT on the pre init hook. The program works by adding " | ||
+ | prompts for each button into the window at pre init. It then checks on a | ||
+ | perpetual process to see if these prompts are in WC_Wi_Next%. If they are | ||
+ | they can be there by either arrowing to the prompt or clicking on the | ||
+ | prompt. Arrowing (or returning) to the prompt should ignore the prompts and | ||
+ | continue on in the direction of travel. Clicking on the prompt with a mouse | ||
+ | should action the code and command. | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | º Customer Id | ||
+ | º Company Name FIRST BANK OF NEW YORK º | ||
+ | º Contact Name Rick Garber | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | Table Mode|10|5|K|{CTRL-F5} | ||
+ | | ||
+ | </ | ||
+ | |||
+ | To determine whether the prompt was clicked on, @PROG.CHAR is checked. If it | ||
+ | is four characters long a mouse click was used. (See above). Note that | ||
+ | WC_Wi_Next% is not reliable when exiting an associated MVed prompt. | ||
+ | Essentially when an AMV group is exited by pressing return, WC_Wi_Next% is | ||
+ | not set. Rather WC_Mv_Next% is set to two more than the count of MVs in the | ||
+ | group! This behaviour is not new, but large thanks to Alan Humphrey/ | ||
+ | Madden of Revelation Technologies for helping to pinpoint it. | ||
+ | |||
+ | The only remaining point of interest is that the window processor obviously | ||
+ | uses the length of the prompt label and entry to work out whether a prompt | ||
+ | has been clicked on using InRect. Originally the program following made the | ||
+ | prompt label equal to the complete button string but this led to false | ||
+ | alarms when clicking ANYWHERE on the prompt line. Hence the use of a | ||
+ | pre-key process to actually draw the button. | ||
+ | |||
+ | < | ||
+ | Subroutine Add_BNS(Branch) | ||
+ | /* | ||
+ | Author | ||
+ | Date Sept 1992 | ||
+ | Notes Note for BP@ read ButtonPrompts@, | ||
+ | */ | ||
+ | GoTo Main | ||
+ | Declare Subroutine Catalyst, VSpace, Delay, Msg | ||
+ | $Insert SysInclude, Window_Common% | ||
+ | $Insert SysInclude, LcPositions | ||
+ | $Insert SysInclude, Virtual.Params | ||
+ | $Insert SysInclude, Logical | ||
+ | $Insert SysInclude, Window.Constants | ||
+ | Equ RegisterToUse$ To 49 ; * Window Register 5 | ||
+ | Equ BnLabel$ To 1 | ||
+ | Equ BnX$ To 2 | ||
+ | Equ BnY$ To 3 | ||
+ | Equ BnCode$ To 4 | ||
+ | Equ BnCommand$ To 5 | ||
+ | Equ Dm$ To Char(247) | ||
+ | |||
+ | Main: | ||
+ | Common /WindowBns/ BP@, BnLabelPrePress@, | ||
+ | BnLabelPress@ | ||
+ | Begin Case | ||
+ | Case Branch = " | ||
+ | Case Branch = " | ||
+ | Case Branch = " | ||
+ | End Case | ||
+ | Return | ||
+ | |||
+ | Perpetual: | ||
+ | CAG = WC_Curr_Amv_Group% | ||
+ | If CAG Then | ||
+ | If WC_Mv_Next%> | ||
+ | * Moving out of an AMV group downwards so the next prompt will be | ||
+ | * equal to the start pos + count of prompts + 1 | ||
+ | WC_Wi_Next%=WC_Amv%< | ||
+ | End | ||
+ | End | ||
+ | Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Then | ||
+ | If Len(@Prog.Char) = 4 Then | ||
+ | * Asked to mouse to Bn prompt so get options code and command and | ||
+ | * execute it | ||
+ | Old_Wi_Next% = WC_Wi_Next% | ||
+ | GoSub BnPress | ||
+ | Catalyst(WC_W%(BP@< | ||
+ | < | ||
+ | If WC_Wi_Next% # Old_Wi_Next% Then | ||
+ | * Do nothing, user must have changed it in catalyst | ||
+ | End Else | ||
+ | * Return whence one came | ||
+ | | ||
+ | End | ||
+ | @Prog.Char = "" | ||
+ | End Else | ||
+ | * Normal attempt to move into the Bn prompt so just increment Wi_Next% | ||
+ | Exit = False$ | ||
+ | Begin Case | ||
+ | Case WC_Wi% = 1 And WC_Wi_Next% = WC_W_Cnt% | ||
+ | Loop | ||
+ | Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Else | ||
+ | Exit = True$ | ||
+ | End | ||
+ | Until Exit | ||
+ | Wi_Next% -= 1 | ||
+ | | ||
+ | Case WC_Wi_Next% > WC_Wi% | ||
+ | Loop | ||
+ | WC_Wi_Next% += 1 | ||
+ | Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Else | ||
+ | Exit = True$ | ||
+ | End | ||
+ | If WC_Wi_Next% > WC_W_Cnt% Then | ||
+ | | ||
+ | End | ||
+ | Until Exit Repeat | ||
+ | Case WC_Wi_Next% < WC_Wi% | ||
+ | Loop | ||
+ | WC_Wi_Next% -= 1 | ||
+ | Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Else | ||
+ | Exit = True$ | ||
+ | End | ||
+ | If WC_Wi_Next% < 1 Then | ||
+ | | ||
+ | End | ||
+ | Until Exit Repeat | ||
+ | End Case | ||
+ | End | ||
+ | End | ||
+ | Return | ||
+ | |||
+ | PreInit: | ||
+ | BnDetails = Field(@Record, | ||
+ | If BnDetails Then | ||
+ | * For each Bn defined, add into prompt array and into labelled common | ||
+ | Convert " | ||
+ | BnCtr = Count(BnDetails, | ||
+ | PromptArray = @Record[1, | ||
+ | PromptCount = PromptArray< | ||
+ | For X = 1 To BnCtr | ||
+ | | ||
+ | Bn = BnDetails< | ||
+ | | ||
+ | | ||
+ | GoSub ConstructBnLabel | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Next | ||
+ | PromptArray< | ||
+ | @Record = FieldStore(@Record, | ||
+ | @Record = FieldStore(@Record, | ||
+ | BP@ = "" | ||
+ | Top = PromptCount | ||
+ | Bottom = Top - BnCtr + 1 | ||
+ | For X = Bottom To Top | ||
+ | | ||
+ | Next | ||
+ | End | ||
+ | * Finally add Perpetual and Pre Key call in if not there | ||
+ | PerpetualCall = Field(@Record, | ||
+ | Begin Case | ||
+ | Case PerpetualCall< | ||
+ | | ||
+ | Case Index(PerpetualCall< | ||
+ | Null | ||
+ | Case 1 | ||
+ | | ||
+ | | ||
+ | End Case | ||
+ | @Record = FieldStore(@Record, | ||
+ | PreCode = @Record< | ||
+ | PostCode = @Record< | ||
+ | Begin Case | ||
+ | Case Index(@Record< | ||
+ | Null | ||
+ | Case 1 | ||
+ | | ||
+ | | ||
+ | End Case | ||
+ | Delay(0) | ||
+ | Return | ||
+ | |||
+ | ConstructBnLabel: | ||
+ | BnText = Bn<0, BnLabel$> | ||
+ | BnX = Bn<0, BnX$> | ||
+ | BnY = Bn<0, BnY$> | ||
+ | BnLabelLength = Len(BnText) | ||
+ | BnLabelTemp = @(BnX,BnY- 1):" | ||
+ | BnLabelTemp := @(BnX, | ||
+ | BnLabelTemp := @(BnX, | ||
+ | BnLabelPrePress@< | ||
+ | BnLabelTemp = @(BnX,BnY- 1):" | ||
+ | BnLabelTemp := @(BnX, BnY) : " | ||
+ | BnLabelTemp := @(BnX, | ||
+ | BnLabelPress@< | ||
+ | Return | ||
+ | |||
+ | BnPress: | ||
+ | X = WC_W%(WC_Wi_Next%)< | ||
+ | Y = WC_W%(WC_Wi_Next%)< | ||
+ | ReleaseColour = WC_W%(WC_Wi_Next%)< | ||
+ | ReleaseBn = ReleaseColour : BnLabelPrePress@< | ||
+ | If Branch = " | ||
+ | | ||
+ | | ||
+ | | ||
+ | Out 67, 182 ; Out 66, 21 ; Out 66, 0 | ||
+ | | ||
+ | Out 97,NewValue | ||
+ | | ||
+ | | ||
+ | Out 97,NewValue | ||
+ | End | ||
+ | Vspace(VPrnt, | ||
+ | Return | ||
+ | |||
+ | SetUpBns: | ||
+ | BnCtr = Count(BP@, @Fm) + 1 | ||
+ | For Ctr = 1 To BnCtr | ||
+ | X = WC_W%(BP@< | ||
+ | Y = WC_W%(BP@< | ||
+ | | ||
+ | | ||
+ | | ||
+ | Next | ||
+ | Return | ||
+ | </ | ||
+ | |||
+ | (Volume 4, Issue 5, Pages 12-15) |