Started by velasquez ·
2015-08-28 20:28 UTC ·
4 replies · SMF topic #2304
velasquez
2015-08-28 20:28 UTC
Is there a way to know dcl-Control-GetValue an Option Button before completing onClicked event?
roy_043
2015-08-28 21:00 UTC
I am not sure what you mean. But you do not need the Option Button's OnClick event to read its value.
velasquez
2015-08-29 11:18 UTC
author=roy_043 link=topic=2304.msg11592#msg11592 date=1440795638 wrote:
I am not sure what you mean. But you do not need the Option Button's OnClick event to read its value.
An OptionButton does a great job when it is selected, yet a user clicks on it again, I want to prevent it do all the work without.
roy_043
2015-08-29 20:13 UTC
You can quite easily use a stored value to prevent the execution of code inside an event handler. See the example below. Note: since the code more or less emulates the built-in functionality of an Option List, using that control may be more convenient for you.
(defun c:YourCommand (
/ c:YourProject/Form1#OnInitialize
c:YourProject/Form1/OptionButton1#OnClicked
c:YourProject/Form1/OptionButton2#OnClicked
oldOption
)
(defun c:YourProject/Form1#OnInitialize ()
(setq oldOption
(cond
((= 1 (dcl-Control-GetValue YourProject/Form1/OptionButton1))
(dcl-Control-GetCaption YourProject/Form1/OptionButton1)
)
((= 1 (dcl-Control-GetValue YourProject/Form1/OptionButton2))
(dcl-Control-GetCaption YourProject/Form1/OptionButton2)
)
(T
""
)
)
)
)
(defun c:YourProject/Form1/OptionButton1#OnClicked (value / caption)
(setq caption (dcl-Control-GetCaption YourProject/Form1/OptionButton1))
(if (/= oldOption caption)
(progn
(setq oldOption caption)
(princ "\nDo your stuff 1 ... ")
)
(princ "\nDo nothing 1 ")
)
)
(defun c:YourProject/Form1/OptionButton2#OnClicked (value / caption)
(setq caption (dcl-Control-GetCaption YourProject/Form1/OptionButton2))
(if (/= oldOption caption)
(progn
(setq oldOption caption)
(princ "\nDo your stuff 2 ... ")
)
(princ "\nDo nothing 2 ")
)
)
(setvar 'cmdecho 0)
(command "_opendcl")
(setvar 'cmdecho 1)
(dcl-Project-Load "YourProject.odcl" T)
(dcl-Form-Show YourProject/Form1)
(princ)
)
velasquez
2015-08-30 10:33 UTC
[quote author=roy_043 link=topic=2304.msg11597#msg11597 date=1440879214]
You can quite easily use a stored value to prevent the execution of code inside an event handler. See the example below. Note: since the code more or less emulates the built-in functionality of an Option List, using that control may be more convenient for you.
Thank you roy