Jump to content

All input and radio buttons reset when hiding a dialog to get point?


Recommended Posts

Posted

Hello,

 

Is it normal that when you have a dialog with several radio buttons and edit boxes, and have a button to do a getpoint the whole dialog is reset after you click to get point?

 

I know that hiding a dialog needs a "loop while", and that works properly but all input is gone whenever I want to getpoint.

 

Its as if a new dialog is started.

 

thx

Posted

I'm afraid that this is the default behaviour - there is not a "true" hide of the form like in other languages. You will need to retain current user input into a temporary list and fill the dialog with those values when re-display it.

Posted

:o

 

Do jou mean a list of "set_tiles" or something else. cause I got 5 groups of radio buttons and its going to be troublesome this way?

Posted

That true, I was saying to use the SET_TILE function to load the values previously set by you user; that it, prior to "hide" the dialog. Don't need to be afraid about effect of those setting on dialog since ACTION_TILE is triggered only on user action.

Posted

Got it.

 

If in dcl code "rb1" has value = 1 and I chose "rb3" in form and when it reloads after hiding, it first sets "rb1" and then "rb3" with set_tile function right.

But its so fast you can't see it doing all that stuff?

 

But how do I set_tile a radio button and a toggle?

 

thx MSasu

Posted

So, "rb1" is the default selection; that it, the option that appear selected when user call your command - I supposed that come from DCL definition. Next the user select the "rb3" option before "hide" the dialog to input a point on screen. When restore the dialog you just have to select from code the "rb3" option; the selection from "rb1" (that come, again, from DCL) is lost automatically - for sure, as long the said buttons are groupped in the same container.

 

To select programmatically a radio-button:

(set_tile "rb3" "1")

Posted
Do jou mean a list of "set_tiles" or something else. cause I got 5 groups of radio buttons and its going to be troublesome this way?

 

MSasu is correct, you will need to store the current values of the various user input tiles and set these values when the dialog is displayed. To provide an example of how this may be accomplished, by program here has 6 buttons that will temporarily suppress the dialog whilst the user either picks an object or distance from the drawing, and the dialog must be reconfigured to the previously entered settings when displayed.

Posted
So, "rb1" is the default selection; that it, the option that appear selected when user call your command - I supposed that come from DCL definition. Next the user select the "rb3" option before "hide" the dialog to input a point on screen. When restore the dialog you just have to select from code the "rb3" option; the selection from "rb1" (that come, again, from DCL) is lost automatically - for sure, as long the said buttons are groupped in the same container.

 

To select programmatically a radio-button:

(set_tile "rb3" "1")

 

I was very close I forgot the double quotes :D thx again MSusu I think I can go forward for now.

 

MSasu is correct, you will need to store the current values of the various user input tiles and set these values when the dialog is displayed. To provide an example of how this may be accomplished, by program here has 6 buttons that will temporarily suppress the dialog whilst the user either picks an object or distance from the drawing, and the dialog must be reconfigured to the previously entered settings when displayed.

 

thx Lee MAC for the examples and for verifying what MSusu said!

Posted
I was very close I forgot the double quotes

Please keep in mind that all functions that deal with DCL accept only strings as arguments.

Posted
Please keep in mind that all functions that deal with DCL accept only strings as arguments.

 

Except mode_tile ;)

Posted
Please keep in mind that all functions that deal with DCL accept only strings as arguments.

 

LEE MAC told me a few days back! Eventually and hopefully it'll stick in my head!

Posted
Except mode_tile ;)

Good observation Lee! Thank you for correction.

Posted (edited)

Hello again,

 

I made the smallest possible code I could come up with for 2 radio buttons, that needs to be refilled in the form with previous data before the hide dialog.

I also made a habit to start with underscore on my dcl keys.

plz. suggestions for other approaches is welcome...

 

 

(action_tile "_rb1" "(setq RB2 nil)")
(action_tile "_rb2" "(setq RB2 T)")

(if RB2 
   (set_tile "_rb2" "1")
   (set_tile "_rb1" "1") ; this makes _rb1 default to!
)

If seems right here but I think condition function is better for more then 3 radio buttons.

Edited by Attila The Gel
Posted

In my programs, I tend to use the DCL key as the stored value for a radio_button, since radio_buttons are controlled as individual tiles.

 

For example:

 

([color=blue]set_tile[/color] key [color=darkred]"1"[/color])
([color=blue]foreach [/color]key '([color=darkred]"radio_key1" "radio_key2" ... "radio_keyN"[/color])
   ([color=blue]action_tile[/color] key [color=darkred]"(setq key $key)"[/color])
)

Posted
In my programs, I tend to use the DCL key as the stored value for a radio_button, since radio_buttons are controlled as individual tiles.

 

For example:

 

([color=blue]set_tile[/color] key [color=darkred]"1"[/color]) [color=red]What is key here? should it not be "key"?[/color]
([color=blue]foreach [/color]key '([color=darkred]"radio_key1" "radio_key2" ... "radio_keyN"[/color])[color=red] key again[/color]
   ([color=blue]action_tile[/color] key [color=darkred]"(setq key $key)"[/color]) [color=red]lots of key and I'm totaly lost now?![/color]
)

 

I don't get this Lee. I've read your code several times but cant grasp it. I'm sorry to not be able to understand what is going on in your code exactly?

Posted

I believe that that code should read in fact:

(foreach key '("radio_key1" "radio_key2" ... "radio_keyN")
(action_tile key [color=red](strcat "(setq " key "$key)")[/color])
)

That excerpt of code defines at run-time the actions associated with some dialog tiles.

What @Lee is exploiting there is the fact that, as stated above, the ACTION_TILE functions require a string as second argument. So, he parse a list of strings, the tile keys, and use the same string to build an attribution statement which define a variable matching key’s name which receive the value of said key.

Posted
I don't get this Lee. I've read your code several times but cant grasp it. I'm sorry to not be able to understand what is going on in your code exactly?

 

Sorry, I had overlooked the initial if expression for the case in which the key variable is null:

([color=blue]if[/color] ([color=blue]null [/color]key)
   ([color=blue]setq [/color]key [font=Courier New][color=darkred][color=darkred]"radio_key1"[/color][/color][/font])
)
([color=blue]set_tile[/color] key [color=darkred]"1"[/color])
([color=blue]foreach [/color]key '([color=darkred]"radio_key1" "radio_key2" ... "radio_keyN"[/color])
   ([color=blue]action_tile[/color] key [color=darkred]"(setq key $key)"[/color])
)

Here, the key symbol stores the key attribute of the radio_tile that is currently active. Hence, when the dialog is first displayed, the symbol key has no initial value (since it would be localised within the calling function) and is arbitrarily set to the key of the first radio tile: "radio_key1"

 

The radio_tile whose key is stored by the variable key is then set to be active.

 

In the foreach loop, the action_tile expressions are set for each radio_tile.

 

Thus, for each radio_tile key in the list of tile keys: '("radio_key1" "radio_key2" ... "radio_keyN"), the action_tile expression is evaluated for the key:

 

([color=blue]action_tile[/color] key [color=darkred]"(setq key $key)"[/color])

Written in full (without the foreach loop), these action_tile expressions would be:

 

([color=blue]action_tile[/color] [color=darkred]"radio_key1"[/color] [color=darkred]"(setq key $key)"[/color])
([color=blue]action_tile[/color] [color=darkred]"radio_key2"[/color] [color=darkred]"(setq key $key)"[/color])
...
([color=blue]action_tile[/color] [color=darkred]"radio_keyN"[/color] [color=darkred]"(setq key $key)"[/color])

Note that the symbol $key is a predefined action expression variable (along with $value / $reason / $data), which stores the key attribute of the tile that triggered evaluation of the action_tile expression.

 

Hence, in each action_tile expression, the variable key is being set to the key attribute of the radio_tile that is selected by the user.

 

If the dialog is then suppressed using a done_dialog / new_dialog call within a loop construct, the string value of the key symbol is used to set the correct radio_tile to be active when the dialog is redisplayed.

Posted
I believe that that code should read in fact:

(foreach key '("radio_key1" "radio_key2" ... "radio_keyN")
(action_tile key [color=red](strcat "(setq " key "$key)")[/color])
)

 

No, the original action_tile expression was what I had intended, but thank you for your interest Mircea.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...