Project

General

Profile

8376-with-focusable.p

Vladimir Tsichevski, 04/24/2024 08:54 AM

Download (5.53 KB)

 
1
// Demonstrates no focus transfer in frames with focusable contents
2
 
3
// In this demo, 5 frames are defined with 8 buttons:
4
// 1. one outermost frame 'outerframe' with 'focusable4' and 'focusable6' buttons
5
// 2. two frames in 'outerFrame':
6
//    # 'innerFrame' (with 'focusable1' and 'focusable2' buttons)
7
//    # 'innerFrame2' (with 'focusable3' and 'focusable8' buttons) .
8
// 3. 'innerMostFrame' in 'innerFrame2' with the 'focusable5' button
9
// 4. 'innerInnerMostFrame' in 'innerMostFrame' with the 'focusable7' button.
10

    
11
// Output message serial number to make message identification easier
12
DEFINE VARIABLE visitCounter AS INTEGER NO-UNDO.
13

    
14
DEFINE BUTTON focusable4.
15
DEFINE BUTTON focusable6.
16
DEFINE FRAME outerFrame
17
  focusable4 AT ROW 3.5 COL 1
18
  focusable6
19
WITH SIZE 80 BY 15.
20

    
21
DEFINE BUTTON focusable1.
22
DEFINE BUTTON focusable2.
23
DEFINE FRAME innerFrame
24
  focusable1 focusable2
25
  WITH SIZE 60 BY 2
26
  AT ROW 1 COL 1.
27
FRAME innerFrame:FRAME = FRAME outerFrame:HANDLE.
28

    
29
DEFINE BUTTON focusable3.
30
DEFINE BUTTON focusable8.
31
DEFINE FRAME innerFrame2
32
  focusable3 focusable8
33
  WITH SIZE 60 BY 10
34
  AT COLUMN 1 ROW 5.
35
FRAME innerFrame2:FRAME = FRAME outerFrame:HANDLE.
36

    
37
DEFINE BUTTON focusable5.
38
DEFINE FRAME innerMostFrame
39
  focusable5
40
  WITH SIZE 50 BY 4
41
  AT COLUMN 1 ROW 6.
42
FRAME innerMostFrame:FRAME = FRAME innerFrame2:HANDLE.
43

    
44
DEFINE BUTTON focusable7.
45
DEFINE FRAME innerInnerMostFrame
46
  focusable7
47
  WITH SIZE 40 BY 2
48
  AT COLUMN 1 ROW 2.5.
49
FRAME innerInnerMostFrame:FRAME = FRAME innerMostFrame:HANDLE.
50

    
51
// Print message number, widget name, message argument and current FOCUS HANDLE
52
// if set
53
PROCEDURE Print:
54
  DEFINE INPUT PARAMETER w AS HANDLE NO-UNDO.
55
  DEFINE INPUT PARAMETER msg AS CHARACTER NO-UNDO.
56
  DEFINE VARIABLE hFocus AS HANDLE NO-UNDO.
57
  hFocus = FOCUS.
58
  DEFINE VARIABLE cFocusName AS CHARACTER NO-UNDO.
59
  IF FOCUS <> ? THEN
60
     cFocusName = FOCUS:NAME.
61
  MESSAGE visitCounter w:NAME msg "FOCUS:" cFocusName.
62
  visitCounter = visitCounter + 1.
63
END PROCEDURE.
64

    
65
// Run the Print procedure with 'ENTRY' as argument
66
PROCEDURE PrintEntry:
67
  DEFINE INPUT PARAMETER w AS HANDLE NO-UNDO.
68
  RUN Print(w, "Entry").
69
  w:BGCOLOR = 2.  
70
END PROCEDURE.
71

    
72
// Run the Print procedure with 'LEAVE' as argument
73
PROCEDURE PrintLeave:
74
  DEFINE INPUT PARAMETER w AS HANDLE NO-UNDO.
75
  RUN Print(w, "Leave").
76
  w:BGCOLOR = 4.  
77
END PROCEDURE.
78

    
79
// Print frame tab ring
80
PROCEDURE PrintTabRing:
81
  DEFINE INPUT PARAMETER fr AS HANDLE NO-UNDO.
82
  DEFINE VARIABLE w AS HANDLE NO-UNDO.
83
  MESSAGE "Tab ring" fr:NAME.
84
  w = fr:FIRST-CHILD:FIRST-TAB-ITEM.
85
  DO WHILE w <> ?:
86
    MESSAGE w:NAME.
87
    w = w:NEXT-TAB-ITEM.
88
  END.  
89
END PROCEDURE.
90

    
91
ON ENTRY OF FRAME outerFrame DO:
92
 RUN PrintEntry(FRAME outerFrame:HANDLE).
93
 //RETURN NO-APPLY.
94
END.
95
ON LEAVE OF FRAME outerFrame DO:
96
 RUN PrintLeave(FRAME outerFrame:HANDLE).
97
 //RETURN NO-APPLY.
98
END.
99

    
100
ON ENTRY OF FRAME innerFrame DO:
101
 RUN PrintEntry(FRAME innerFrame:HANDLE).
102
 //RETURN NO-APPLY.
103
END.
104

    
105
ON LEAVE OF FRAME innerFrame RUN PrintLeave(FRAME innerFrame:HANDLE).
106

    
107
ON ENTRY OF FRAME innerFrame2 RUN PrintEntry(FRAME innerFrame2:HANDLE).
108
ON LEAVE OF FRAME innerFrame2 RUN PrintLeave(FRAME innerFrame2:HANDLE).
109

    
110
ON ENTRY OF FRAME innerMostFrame RUN PrintEntry(FRAME innerMostFrame:HANDLE).
111
ON LEAVE OF FRAME innerMostFrame RUN PrintLeave(FRAME innerMostFrame:HANDLE).
112

    
113
ON ENTRY OF FRAME innerInnerMostFrame RUN PrintEntry(FRAME innerInnerMostFrame:HANDLE).
114
ON LEAVE OF FRAME innerInnerMostFrame RUN PrintLeave(FRAME innerInnerMostFrame:HANDLE).
115

    
116
ON ENTRY OF focusable1 DO:
117
 RUN PrintEntry(focusable1:HANDLE).
118
 //RETURN NO-APPLY.
119
END.
120

    
121
ON LEAVE OF focusable1 DO:
122
 RUN PrintLeave(focusable1:HANDLE).
123
 //RETURN NO-APPLY.
124
END.
125

    
126
ON ENTRY OF focusable2 DO:
127
   RUN PrintEntry(focusable2:HANDLE).
128
END.    
129
ON LEAVE OF focusable2 DO:
130
   RUN PrintLeave(focusable2:HANDLE).
131
END.
132

    
133
ON ENTRY OF focusable3 RUN PrintEntry(focusable3:HANDLE).
134
ON LEAVE OF focusable3 RUN PrintLeave(focusable3:HANDLE).
135

    
136
ON ENTRY OF focusable4 DO:
137
   RUN PrintEntry(focusable4:HANDLE).
138
END.
139
ON LEAVE OF focusable4 DO:
140
   RUN PrintLeave(focusable4:HANDLE).
141
END.
142

    
143
ON ENTRY OF focusable5 RUN PrintEntry(focusable5:HANDLE).
144
ON LEAVE OF focusable5 RUN PrintLeave(focusable5:HANDLE).
145

    
146
ON ENTRY OF focusable6 RUN PrintEntry(focusable6:HANDLE).
147
ON LEAVE OF focusable6 RUN PrintLeave(focusable6:HANDLE).
148

    
149
ON ENTRY OF focusable7 RUN PrintEntry(focusable7:HANDLE).
150
ON LEAVE OF focusable7 RUN PrintLeave(focusable7:HANDLE).
151

    
152
ON ENTRY OF focusable8 RUN PrintEntry(focusable8:HANDLE).
153
ON LEAVE OF focusable8 RUN PrintLeave(focusable8:HANDLE).
154

    
155
ON CHOOSE OF focusable1 DO:
156
   ENABLE focusable2  WITH FRAME innerFrame.
157
END.
158

    
159
ON 'a' ANYWHERE DO:
160
  DEFINE VARIABLE hFocus AS HANDLE NO-UNDO.
161
  hFocus = FOCUS.
162
  DEFINE VARIABLE cFocusName AS CHARACTER NO-UNDO.
163
  IF FOCUS <> ? THEN
164
     cFocusName = FOCUS:NAME.
165
  MESSAGE "FOCUS:" cFocusName.
166
END.
167

    
168
//RUN PrintTabRing(FRAME outerFrame:HANDLE). // focusable4, focusable6, innerFrame, innerFrame2
169

    
170
//ENABLE ALL WITH FRAME innerFrame2. // Temporarily
171

    
172
RUN PrintTabRing(FRAME outerFrame:HANDLE).
173
ENABLE focusable4 focusable6 WITH FRAME outerFrame.
174
RUN PrintTabRing(FRAME outerFrame:HANDLE).
175
ENABLE focusable6 focusable4 WITH FRAME outerFrame.
176
RUN PrintTabRing(FRAME outerFrame:HANDLE).
177

    
178
//RUN PrintTabRing(FRAME outerFrame:HANDLE). // innerFrame(1,2), innerFrame2(3), focusable4, focusable5
179

    
180
ENABLE focusable2 WITH FRAME innerFrame.
181
ENABLE ALL WITH FRAME innerMostFrame.
182
ENABLE focusable7 WITH FRAME innerInnerMostFrame.
183

    
184
//RUN PrintTabRing(FRAME outerFrame:HANDLE). // innerFrame, innerFrame2, focusable4, focusable5
185

    
186
// OE Now enabled: 2, 4, 6, 5. Focused: 2
187
// 
188

    
189
WAIT-FOR GO OF FRAME outerFrame.
190
//WAIT-FOR GO OF THIS-PROCEDURE.
191