我有一个窗口中所有小部件的RETURN / CURSOR-DOWN代码,基本上就像按下了TAB一样。它工作正常,但我想要RETENT(默认当前行分为两行)/ CURSOR-DOWN的EDITOR小部件的默认功能。
我试过补充一下
APPLY "ENTER" TO SELF.
要么
APPLY "RETURN" TO SELF.
要么
APPLY "CTRL-J" TO SELF. /*Ctrl-Enter*/
对于EDITOR小部件,但在EDITOR中按RETURN / CURSOR-DOWN时它只是没有做任何事情。它保持不动,就好像没有按下RETURN / CURSOR-DOWN一样。
ON RETURN OF {&WINDOW-NAME} ANYWHERE
DO:
IF SELF:TYPE="EDITOR" THEN
DO:
APPLY "ENTER" TO SELF. /*Does NOT Work*/
END.
ELSE IF SELF:TYPE = "BUTTON" THEN
DO:
APPLY "Choose".
END.
ELSE
DO:
APPLY "Tab".
RETURN NO-APPLY.
END.
END.
ON CURSOR-DOWN OF {&WINDOW-NAME} ANYWHERE
DO:
IF SELF:TYPE="EDITOR" THEN
DO:
APPLY "CURSOR-DOWN" TO SELF. /*Does NOT Work*/
END.
ELSE
DO:
APPLY "Tab".
RETURN NO-APPLY.
END.
END.
有办法吗?
我在10.2B08测试了这个。这是主要的任何触发器:
ON RETURN OF {&WINDOW-NAME} ANYWHERE DO:
IF SELF:TYPE = "BUTTON" THEN DO:
APPLY "Choose".
END.
else do:
apply 'tab'.
return no-apply.
end.
end.
ON CURSOR-DOWN OF {&WINDOW-NAME} ANYWHERE DO:
if self:type ne 'EDITOR' then DO:
APPLY "Tab".
RETURN NO-APPLY.
END.
END.
与你所拥有的没什么不同。现在在编辑器中,向RETURN添加一个触发器,向CURSOR-DOWN添加一个触发器。这是你的编辑器的RETURN触发器:
self:insert-string(chr(13)).
这是编辑器的CURSOR-DOWN触发器:
DEFINE VARIABLE iOffset AS INTEGER NO-UNDO.
assign iOffset = self:cursor-char
self:cursor-line = self:cursor-line + 1
self:cursor-char = ioffset no-error.
do while error-status:get-message(1) begins '**Unable to set attribute CURSOR-CHAR':
assign iOffset = iOffset - 1
self:cursor-char = ioffset no-error.
if iOffset = 1 then leave.
end.
如果这对您有用,请告诉我。在这里似乎对我没问题。