CHUI event question

jmaynar8

New Member
Hello

I am using character mode Progress version 8. I have a window with a field and two buttons. In the ON LEAVE event of the field I use a message box with a yes-no button updating a local logical variable. I also have an "OK" button that performs special logic.

I find that if I click on the OK button and it triggers the ON LEAVE and displays the message box, the CHOOSE event of the ok button does not fire.

Any idea on how I can get the CHOOSE event of the ok button to fire when click on?

Appreciate any help I can get.

Thanks in advance

Jim
 

Serj HAMMER

Junior Racer
Please, show model

As I understand, you "click" Ok, then fires trigger ON-LEAVE, you also choose "Yes" and you whant to continue Ok-trigger?

I think, it will, because this is build-in logic.
If Ok-trigger "not fired" (i.e. "aborted"? - it was started, when you "click" Ok) - please show some src-text with model of your program logic.
 

jmaynar8

New Member
Sample Code

Hello

AS requested here is the code, if the message box in the f_log_overwrite is commented out it works fine.

FUNCTION f_log_Overwrite_Pos RETURNS LOGICAL
(INPUT p_chrHotKey AS CHAR).
DEFINE VARIABLE l_intIndex AS INTEGER.
DEFINE VARIABLE l_logAns AS LOGICAL.
ASSIGN l_intIndex = ASC(p_chrHotKey) - 64.
IF LENGTH (TRIM (v_chrOptions [l_intIndex])) > 0 THEN DO:
ASSIGN l_logAns = FALSE.
BELL.
/** Note if i comment out the message it works fine **/
MESSAGE SKIP (1)
"Position"
CAPS (v_chrHotKey3)
"is already filled, do you want to overwrite it?"
SKIP (1)
VIEW-AS ALERT-BOX WARNING BUTTONS YES-NO
UPDATE l_logAns.
IF NOT l_logAns THEN
RETURN FALSE.
END.
RETURN TRUE.
END FUNCTION. /** f_log_Overwrite **/
FUNCTION f_log_VerifyHotKey RETURNS LOGICAL
(INPUT p_chrHotKey AS CHAR
,INPUT p_intFrame AS INTEGER).
DEFINE VARIABLE l_chrHotKey AS CHAR.
ASSIGN l_chrHotKey = CAPS (p_chrHotKey).
IF LENGTH (TRIM (l_chrHotKey)) = 0 THEN DO:
BELL.
MESSAGE SKIP (1)
"You must provide a Hot Key position for the Menu Item."
SKIP (1)
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
CASE p_intFrame:
WHEN 1 THEN
APPLY "ENTRY" TO v_chrHotKey IN FRAME fraItem.
WHEN 2 THEN
APPLY "ENTRY" TO v_chrHotKey2 IN FRAME fraHotKey.
WHEN 3 THEN
APPLY "ENTRY" TO v_chrHotKey3 IN FRAME fraHotKey.
END CASE.
RETURN FALSE.
END.
IF ASC (l_chrHotKey) < 65 OR ASC (l_chrHotKey) > 88 THEN DO:
BELL.
MESSAGE SKIP (1)
"Invalid Hot Key enter A - X "
SKIP (1)
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
CASE p_intFrame:
WHEN 1 THEN
APPLY "ENTRY" TO v_chrHotKey IN FRAME fraItem.
WHEN 2 THEN
APPLY "ENTRY" TO v_chrHotKey2 IN FRAME fraHotKey.
WHEN 3 THEN
APPLY "ENTRY" TO v_chrHotKey3 IN FRAME fraHotKey.
END CASE.
RETURN FALSE.
END.
CASE p_intFrame:
WHEN 1 THEN DO:
ASSIGN v_chrHotKey = l_chrHotKey.
DISPLAY v_chrHotKey WITH FRAME fraItem.
END.
WHEN 2 THEN DO:
ASSIGN v_chrHotKey2 = l_chrHotKey.
DISPLAY v_chrHotKey2 WITH FRAME fraHotKey.
END.
WHEN 3 THEN DO:
ASSIGN v_chrHotKey3 = l_chrHotKey.
DISPLAY v_chrHotKey3 WITH FRAME fraHotKey.
END.
END case.
RETURN TRUE.

END FUNCTION. /** f_log_VerifyHotKey **/
ON CHOOSE OF btnOk IN FRAME fraHotKey DO:
IF v_chrHotKey3:VISIBLE IN FRAME fraHotKey THEN DO:
IF NOT f_log_VerifyHotKey (INPUT INPUT v_chrHotKey3
, INPUT 3) THEN
RETURN NO-APPLY.
END.
ASSIGN v_logOk = TRUE.
END. /** CHOOSE OF brnOk IN FRAME fraHotKey **/
ON LEAVE OF v_chrHotKey3 IN FRAME fraHotKey DO:
DEFINE VARIABLE l_intIndex AS INTEGER.
DEFINE VARIABLE l_logAns AS LOGICAL.
IF LAST-EVENT:WIDGET-ENTER = btnCancel:HANDLE IN FRAME fraHotKey THEN
RETURN.
IF CAPS (INPUT v_chrHotKey2) = CAPS (INPUT v_chrHotKey3) THEN DO:
BELL.
MESSAGE SKIP (1)
"Cannot move a menu item to its own position."
SKIP (1)
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
APPLY "ENTRY" TO v_chrHotKey2 IN FRAME fraHotKey.
RETURN NO-APPLY.
END.
IF NOT f_log_VerifyHotKey (INPUT INPUT v_chrHotKey3
, INPUT 3) THEN
RETURN NO-APPLY.
/** Check if item already defined at the new position **/
IF NOT f_log_Overwrite_Pos (INPUT INPUT v_chrHotKey3) THEN DO:
APPLY "ENTRY" TO v_chrHotKey3 IN FRAME fraHotKey.
RETURN NO-APPLY.
END.
RETURN.
END. /** LEAVE OF v_chrHotKey3 **/
 

Serj HAMMER

Junior Racer
no idea...

I make the same model in my environment (9.1D, tty, linux) and it works fine. IMHO you have some "hidden" logic, that you don't see.

Code:
function f1 returns logical (input pstr as character):
/* define variable fl as logical no-undo. */

  message "is correct?" "[" + pstr + "]"
    /* VIEW-AS ALERT-BOX WARNING  BUTTONS YES-NO UPDATE fl. */
       VIEW-AS ALERT-BOX question buttons yes-no update fl as logical.

  return fl.
end function.

define variable fill1 as character no-undo.
define button lok label "ok".
define variable lflag as logical no-undo.
define frame fshow fill1 lok with centered.

on leave of fill1 do:
  lflag = f1(self:screen-value).
  message "P1" lflag view-as alert-box.
  if not lflag then return no-apply.
  return.
end.

on go anywhere apply "choose" to lok in frame fshow.
on choose of lok do:
  MESSAGE "p2" view-as alert-box.
end.

enable all with frame fshow.
wait-for end-error of current-window
      or choose of lok.
When I pressing F1 on fill1 - message "is_correct?" was shown. And if I answer "Yes" - message "P1" and "P2" shown also.
 
Top