Jump to content

Update Dialogs Fields while typing


Recommended Posts

so i spent some time today building dialog boxes to learn how they work and I'm actually having some fun with it. 

 

is it possible to update other fields based on a vs.CreateEditText() field? id like to be able to type something in there and then it update a static text field somewhere else in the dialog box. preferably in real time... i see theres a vs.NotifyPullDownClicked(),  which means theres some sort of functionality like that already. 

 

also is there a way to set a statictext field ALL THE WAY to the right side of the dialog box? basically above the OK button.

Link to comment

Hello @Jayme McColgan,

   Since the dialog event handler script runs every time you type in your dialog, you can process each character as you type it and update another field at the same time. Use vs.GetItemText() ro read your typed data. In the IF clause for the EditText item use vs.SetControlText() to update a static text field. 

 

   You can also change EditReal and EditInteger fields in real time with calls to vs.SetEditReal() and vs.SetEditInteger(), respectively. This can be used when two fields are linked like Radius and Diameter of a circle or arc. Changing one updates the other.

 

   To your second question, I haven't tried this in the sense you are referring, but you could play with vs.SetEdgeBinding(). I've used it in resizable dialogs but never in a fixed dialog. Also, there is vs.AlignItemEdge(). I've tried to get things to right align with it but haven't done so satisfactorily, and always resorted to other layout methods.

 

HTH,

Raymond

  • Like 1
Link to comment
On 12/16/2021 at 1:37 AM, MullinRJ said:

Hello @Jayme McColgan,

   Since the dialog event handler script runs every time you type in your dialog, you can process each character as you type it and update another field at the same time. Use vs.GetItemText() ro read your typed data. In the IF clause for the EditText item use vs.SetControlText() to update a static text field. 

 

   You can also change EditReal and EditInteger fields in real time with calls to vs.SetEditReal() and vs.SetEditInteger(), respectively. This can be used when two fields are linked like Radius and Diameter of a circle or arc. Changing one updates the other.

 

   To your second question, I haven't tried this in the sense you are referring, but you could play with vs.SetEdgeBinding(). I've used it in resizable dialogs but never in a fixed dialog. Also, there is vs.AlignItemEdge(). I've tried to get things to right align with it but haven't done so satisfactorily, and always resorted to other layout methods.

 

HTH,

Raymond

that my friend is exactly what i was looking for! thank you! 

Link to comment

Here is a sample for those looking at this later on in life....

 

import vs
from datetime import datetime

def Dialog_Handler(item , data):
    time = str(datetime.now().strftime("%m/%d/%Y %I:%M:%S %p")).replace(" ", "") ### Get current time and removes spaces
    wallname = vs.GetItemText(dialog1, 25) ### Get the value of the text field you are updating
    vs.SetItemText(dialog1, 23, f"{vs.GetFName()}_{wallname}_{time}.png") ### Pushes the new data to a field of your choice

 

Edited by Jayme McColgan
Link to comment

Hello @Jayme McColgan,

   I'm not sure. I know you can display Symbols as a dialog control item, so possibly you could create a temporary symbol and update it as you change dialog fields, then update the dialog display to show the change. See vs.CreateSymbolDisplayControl() and vs.CreateSymDispCtrlN(). Also, you can launch another dialog with the push of a button in the first dialog. This I've done before. What you put in the second dialog is wide open, but you must close the second dialog to return control to the first.

 

Good luck,

Raymond

Link to comment
  • 3 weeks later...
  • 3 weeks later...
On 12/18/2021 at 6:50 AM, MullinRJ said:

Hello @Jayme McColgan,

   I'm not sure. I know you can display Symbols as a dialog control item, so possibly you could create a temporary symbol and update it as you change dialog fields, then update the dialog display to show the change. See vs.CreateSymbolDisplayControl() and vs.CreateSymDispCtrlN(). Also, you can launch another dialog with the push of a button in the first dialog. This I've done before. What you put in the second dialog is wide open, but you must close the second dialog to return control to the first.

 

Good luck,

Raymond

which function will read the state of a push buttom pressed or not? Tried VS.GetBooleanItem () and couple others , still have not figured it out yet. 

 

Thanks

Link to comment

when you press a button it should return the number of the button pressed, you can then process the logic you need to from there. heres an example

import vs
dialog1 = 0

def start():
    global dialog1
    dialog1 = vs.CreateLayout('Pixel Map Exporter', False, 'OK', 'Cancel')
    vs.CreatePushButton(dialog1, 5, "Im a button!")
    vs.SetFirstLayoutItem(dialog1, 5)
    result = vs.RunLayoutDialog(dialog1, Dialog_Handler4)
    return(result)

def Dialog_Handler4(item , data):
  
  	### Init Setup
    if item == 12255:
      pass
	
    ### Finished
    elif item == 1:
        pass

    ### Canclled
    elif item == 2:
        pass

    ### Push Buutton Pressed based off the item number you gave it when building the dialog layout
    elif item == 5:
        vs.AlrtDialog(str(f"Pushed button! im item #{item}"))

    return None

 

  • Like 1
Link to comment
20 hours ago, Jayme McColgan said:

when you press a button it should return the number of the button pressed, you can then process the logic you need to from there. heres an example

import vs
dialog1 = 0

def start():
    global dialog1
    dialog1 = vs.CreateLayout('Pixel Map Exporter', False, 'OK', 'Cancel')
    vs.CreatePushButton(dialog1, 5, "Im a button!")
    vs.SetFirstLayoutItem(dialog1, 5)
    result = vs.RunLayoutDialog(dialog1, Dialog_Handler4)
    return(result)

def Dialog_Handler4(item , data):
  
  	### Init Setup
    if item == 12255:
      pass
	
    ### Finished
    elif item == 1:
        pass

    ### Canclled
    elif item == 2:
        pass

    ### Push Buutton Pressed based off the item number you gave it when building the dialog layout
    elif item == 5:
        vs.AlrtDialog(str(f"Pushed button! im item #{item}"))

    return None

That is good to know, problem solved.

Thank you!

Link to comment

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
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...