Programmatically change GUI controls/ prevent event firing

Hi,
I often construct GUIs where user input in one control automatically changes other controls.
A (simple) example:
A GUI contains controls A and B. When the user changes control A the value of control B has to be adjusted, and the other way round. So the event handler of A tells B to change its value. An event is fired, and the event handler of B tells A to change its value. An event is fired... and you have an endless event handling loop.
Please believe me, though the example is simple: this happens frequently in real life, too. Since setting Swing controls programmatically most often triggers events, I need a mechanism to prevent event handling loops. What I do so far is
o set a "deaf" flag
o change the control
o the listener gets informed about the change, but since the "deaf" flag is set it does nothing
o reset the "deaf" flag
Another, equally awkward way, is removing event listeners before the change and reattaching them afterwards.
Is there any elegant way to handle this? How do you handle this kind of problem, which can't be too rare in the GUI world (although a rather extensive search with Google did not find much)?
Chris

Personally, I usually choose the same approach as you did, implementing a flag which I'll check when events are fired. If you do this, however, be sure to make the flag volatile, otherwise it might (very rarely) happen that a thread caches the value (even though this points to faulty code on your side, it is well near impossible to debug). I would strongly recomment not to remove and readd the listeners since it will create a lot of overhead and is rather hard to maintain.

Similar Messages

  • Programmatically change numeric control increment

    Hi! I need to programmatically change the increment to a numeric control.
    How would I do this in LV6.02? I tried using custom controls (arrows) and an
    indicator and adding/subtracting the increment (separate control) to the
    value. This works ok but my loop runs at 250ms so it updates real slow. Any
    ideas?
    As far as I know LV5 never had the facility but does LV6?
    Leon

    I've used 2 boolean controls (up/down). When either is clicked, the
    increment (standalone numeric control) is added/subtracted to the value, the
    result of which is displayed on a numeric indicator placed beside the
    up/down arrows (makes it look like its an ordinary numeric control). The
    problem is the booleans are read only once every 250ms, causing the
    increment to take place at 4 times a second. If, however, it was a standard
    numeric control, I could change value regardless of loop time (even though
    it would be read only when the loop executed).
    I will try your suggestion. If the control is invisible, will I be able to
    access the arrows? Thanks.
    Leon
    "PdB_Serenity_nl" wrote in message
    news:[email protected]
    com...
    > Have you tried using an invisible (transparant) control on top of the
    > corresponding indicator?
    > Takes less time to draw so your UI-loop can be made more quickly.
    > Or what about a mechanism for detecting that you pressed the up/down
    > button to make the increase-decrease value bigger?

  • Programmatically changing the Control Type of ViewCriteriaItem

    Our requirement is dynamically changing the Control Type (Date, LOV, Combo box, etc) of ViewCriteriaItem.
    We are trying in the following way,
    ViewCriteriaManager vm = view.getViewCriteriaManager();
    oracle.jbo.ViewCriteria vca[] = vm.getAllViewCriterias();
    oracle.jbo.ViewCriteria vc = vca[0];
    vc.removeAllElements();
    ViewCriteriaRow vcr = vc.createViewCriteriaRow();
    vcr.setAttribute((String)viewItemRow.getAttribute("WvciColumnName"),"");
    ViewCriteriaItem vc_item1 = vcr.ensureCriteriaItem((String)viewItemRow.getAttribute("WvciColumnName"));
    // Based on some condition
    vc_item1.setProperty(ViewCriteriaItem.CONTROL_TYPE, ViewCriteriaItem.ControlType.DATE);
    But the control type is not changed in UI?
    Kindly help us
    Regards,
    Vijay

    Hi Sonny:
    Finally I've solved the problem in Java mapping program, changing the content-type parameter like this:
         public void setParameter(Map mParametro)
              this.mParametro=mParametro;
              if (mParametro==null)
                   this.mParametro=new HashMap();
              mParametro.put(StreamTransformationConstants.CONTENT_TYPE, "text/xml");
    I hope it helps you. Regards,
    Alejandro.

  • How to change the attributes of GUI CONTROLS in my own program.

    hi all,
    i just want to change the attributes of GUI CONTROLS in my own program.
    for example `
    How to set an ICON on my GUI BUTTON in the program?
    so what's the mapping between CONTROL in the SCREEN PAINTER and variable in the program?

    Hi Chao Liu,
    Ya , u first find out the PF-STATUS of the screen and goto that status and now u can modify the ICON u want .
    Finding the GUI status of the screen
    Goto that  TRANSACTION CODE or SCREEN
    On the Standard Menu bar Goto ( Menu path) System --> Status
    Now u get a pop-up System :status in that in SAP Data block u can find GUI Status. Now Double Click on that Status. It takes u to the Status of that screen.
    Now click on the Display --> Change Button on the application tool bar.
    If it is a standard GUI-status then it asks for the ACCESS KEY.
    if it is a custom defined GUI Status  then u can change the status .
    reward if helpful
    raam

  • Can you programmatically change the width of columns in a table control\indicator

    Is it possible to programmatically change the width of columns in a table control\indicator ie to fit to width of the data or in my case the header information.

    Create a property node (or reference) and use the 'Active Cell' property to select which column you want to change and then use the 'Cell size'--> 'Width' property to change the size.
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
    Attachments:
    table.vi ‏33 KB

  • Is that possible to change parent of GUI Controll?

    Hi,
    I have to change parent of GUI Control. I have a Splitter with two Controls (b.e. 1 x 2 )and would like to delete one. After that I would like to change grid ( 1 x 1 ) and show in this the second view. But after I have called splitter->set_grid(1 1) my container which include second  view is no more valid, I have to get new one from splitter but how can I bind it with my view?
    Regards
    Bogdan

    Hello Bogdan
    If you look at the parent attribute of different classes (e.g. CL_GUI_ALV_GRID, CL_GUI_ALV_TREE) then it is a public, <b>READ-ONLY</b> instance attribute. Based on this property I would assume that it is not possble to switch the parent of a GUI control.
    Regards
      Uwe

  • How can I programmatically change the fill color Settings of the Cwslide ActiveX Controls

    In design mode (Visual Studio 6.0),I want to programmatically change the fill color in properties of  cwslide  ActiveX Controls.what's the command?
    Attachments:
    cwslide.JPG ‏11 KB

    First, if you want to start getting beyond the basics with DAQ, you are going to have to stop using the DAQ assistant and do it with lower level DAQmx VI's.  There are hundreds of examples in the example finder.  You can even right click on the DAQ assistant and select open front panel.  That will create a subVI that you can open and see what is going on behind the scenes.  Do it.  I think you'll find the DAQ task is being recreated on each (though I'm not 100% of how the settings are established or maintained in each section of that subVI).
    The second problem is you have a bit of a race condition on iteration 0.  Those two DAQ property nodes are running at the same time.  So when you read the AI.Max, it may be happening before or after the AI.Max is set in your case structure.
    Third, make sure you wire up your error wires.

  • Capturing events fired by ACtiveX control

    How can i capture events fired by ACtiveX control. i am using RegEventCallback vi, but that controls user driven events. i have an activeX control that fires events at unspecified time, now i want to know how to handle such events in LabView.
    Rubina

    Hi InformaticsComplex,
    Using the Register Event Callback VI is the correct method to capture events generated by an ActiveX control. Register Event Callback registers a VI to be called when the event occurs. I suggest checking out the LabVIEW Help articles Using ActiveX with LabVIEW and Register Event Callback as well as the following examples. I hope this helps!
    Examples (all found in NI Example Finder):
    ActiveX Event Callback for Excel VI: labview\examples\comm\axevent.llb
    ActiveX Event Callback for IE VI: labview\examples\comm\axevent.llb
    NET Event Callback for Calendar Control VI: labview\examples\comm\dotnet\Events.llb
    NET Event Callback for DataWatcher VI: labview\examples\comm\dotnet\Events.llb
    Mike Lyons
    National Instruments
    http://www.ni.com/devzone

  • Suspending event firing

    Hi Everyone....
    I have a series of segmented controls on my panel. I have set the default to be all segment 2 to be the value at design time.
    Now when i populate the controls with the value from the database, the event for segment changed gets fired.
    I would like to suspend the segment changed event until after i load the form with data.
    Is this possible and how do i do it?
    thanks
    tony

    Hi Tony -
    Based on some of your recent posts, I'm assuming your question is about UISegmentedControl in the iPhone SDK. Though the corresponding AppKit control is similar in many ways, I haven't considered NSSegmentedControl in this response.
    alt-088 wrote:
    ... when i populate the controls with the value from the database, the event for segment changed gets fired.
    I'm not sure I know what you mean by "populate the controls". Do you mean setting the title of each segment? I don't think a programmatic change in the title should be generating a UIControlEventValueChanged event. In general, controls only send action messages in response to a user action--in this case a tap on one of the segments.
    Do you mean the user is tapping one or more segments before the data is finished loading? In that case it might be best to disable all the controls until the program is ready to handle a touch event. If the data load takes a noticeable amount of time, I think the user might be confused if the response to a tap were delayed.
    I would like to suspend the segment changed event until after i load the form with data.
    Is this possible and how do i do it?
    Yes, there are lots of ways you could do that. For example, you could maintain a boolean ivar to indicate whether a new data load was required or in progress. Each action method could test that ivar and if the data wasn't ready, the method would set an actionPending ivar instead of completing the action. When the data was ready, any pending actions would be handled. If necessary, 'actionPending' could be an array containing the address of each UISegmentControl which had fired before or during the load. E.g.:
    - (IBAction)segmentChanged:(id)sender {
    if (self.dataReady == NO) {
    [self.actionPending addObject:sender];
    else {
    UISegmentedControl *control = sender;
    int tag = control.tag;
    int segment = control.selectedSegmentIndex;
    // do something based on tag and segment
    - (void)dataIsReady {
    self.dataReady = YES;
    for (UISegmentControl *control in actionPending) {
    [self segmentChanged:control];
    [actionPending removeAllObjects];
    Note if any of the segment controls is momentary, you'll need to store more data in actionPending since control.selectedSegmentIndex is only valid during the event cycle started by a segment tap.
    Once again, I question the need for a delayed response to segment taps. But if that's what you really want, something like the above example should work for you.
    - Ray

  • Events firing in infinite loop

    Hello,
    I have two date fields (a start date and a due date) and a text field for the user to enter a duration between the two dates.  I've added separate event listeners for each component and the problem I'm having is when one field is updated, the event listener calculates the date for the other one as well and when the value changes, its event listener fires and changes the other date, causing an infinite loop.
    I've tried to remove the event listeners on the other components at the beginning of the listeners and adding them back at the end of the listeners, but the events still seem to fire when adding the listener.
    Is there an easy way to prevent event handlers from being run when you are changing one component's value from the event listener of another component?

    Try calling validateNow() on the controls before reattaching listeners
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Qt_ended Event firing in IE

    I want to add image at end of quicktime movie,for that i m firing qt_ended and its working alright in Firefox,for IE im getting confused abt what change i have to made.Read the tutorial here http://developer.apple.com/library/safari/#documentation/QuickTime/Conceptual/QT ScriptingJavaScript/bQTScripting_JavaScri_Document/QuickTimeandJavaScri.html#//appleref/doc/uid/TP40001526-CH001-SW6 But unable to make it work.If someone can please give me some example for making me do above functionality in IE.Below is my code
    <script src="AC_QuickTime.js" language="JavaScript" type="text/javascript">
    </script>
    <script language="JavaScript" type="text/javascript">
    <!--
    /* define function that shows percentage of movie 1 loaded */
    function showProgress()
    var percentLoaded = 0 ;
    percentLoaded = parseInt((document.movie1.GetMaxTimeLoaded() / document.movie1.GetDuration()) * 100);
    document.getElementById("loadStatus1").innerHTML = 'Movie loading: ' + percentLoaded + '% complete...';
    /* define function that executes when movie1 loading is complete */
    function movieLoaded()
    document.getElementById("loadStatus1").innerHTML = "Movie Loaded" ;
    /* define function that shows percentage of movie 2 loaded */
    function showProgress2()
    var percentLoaded = 0 ;
    percentLoaded = parseInt((document.movie2.GetMaxTimeLoaded() / document.movie2.GetDuration()) * 100);
    document.getElementById("loadStatus2").innerHTML = 'Movie loading: ' + percentLoaded + '% complete...';
    /* define function that executes when movie2 loading is complete */
    function movieLoaded2()
    document.getElementById("loadStatus2").innerHTML = "Movie Loaded" ;
    /* define function that adds another function as a listener for a DOM event */
    function myAddListener(obj, evt, handler, captures)
    if ( document.addEventListener )
    obj.addEventListener(evt, handler, captures);
    else
    // IE
    alert("IN IE");
    obj.attachEvent('on' + evt, handler);
    /* define functions that register each listener */
    function RegisterListener(eventName, objID, embedID, listenerFcn)
    var obj = document.getElementById(objID);
    if ( !obj )
    obj = document.getElementById(embedID);
    if ( obj )
    myAddListener(obj, eventName, listenerFcn, false);
    function alertonend()
    //document.getElementById("loadStatus2").innerHTML = "Movie Loaded" ;
    alert("HEREEE");
    /* define a single function that registers all listeners to call onload */
    function RegisterListeners()
    RegisterListener('qt_progress', 'movie1', 'qtmovie_embed', showProgress);
    RegisterListener('qt_load', 'movie1', 'qtmovie_embed', movieLoaded);
    RegisterListener('qt_progress', 'movie2', 'qtmovie_embed2', showProgress2);
    RegisterListener('qt_load', 'movie2', 'qtmovie_embed2', movieLoaded2);
    RegisterListener('qt_ended', 'movie1', 'qtmovie_embed', alertonend);
    //-->
    </script>
    Two Movies with JavaScript Play/Stop Controls
    and Progress/Load Monitors
    <script language="javascript" type="text/javascript">
    QT_WriteOBJECT('b.mp4', '760','416', '', 'obj#id', 'movie1', 'emb#id', 'qtmovie_embed', 'emb#name', 'movie1', 'postdomevents', 'true', 'enablejavascript', 'true');
    </script>   
    <!--<script language="javascript" type="text/javascript">
    QTWriteOBJECT('samplesorenson.mov', '360','256', '', 'obj#id', 'movie2', 'emb#id', 'qtmovie_embed2', 'emb#name', 'movie2', 'postdomevents', 'true', 'enablejavascript', 'true');
    </script>-->
    <table width="100%">
    <tr>
    <td align="center">
    MOVIE LOADING...
    </td>
    <td align="center">
    MOVIE LOADING...
    </td>
    </tr>
    <tr>
    <td align="center">
    Play 1
    </td>
    <td align="center">
    Play 2
    </td>
    </tr>
    <tr>
    <td align="center">
    Stop 1
    </td>
    <td align="center">
    Stop 2
    </td>
    </tr>
    </table>

    Very curious to see answers to this post — I'm not getting a 'qt_ended' event in either Safari or Firefox (3.5.2). Nor were some of the other events firing (qt_timechanged comes to mind). Have noticed numerous messages on boards regarding troubles with the QT events, so I may just keep using my workarounds -- setInterval() monitoring loops.
    N

  • Programmatic instantiation of  'controls'

    I' trying to programmatically test my controls but ...
    I have a java control project containing a control. I have a web project running
    cactus. I have a test case instantiating programmatically the control using
    MyControlBean myControlBean
    = (MyControlBean) java.beans.Beans.instantiate( null ,"controls.MyControlBean").
    When it runs the URLClassloader generates *** ClassNotFound *** for controls.MyControlBean.
    The control does exist with the libraries tab in a jar as expected. I haven’t
    changed any class loading options. If I export to an ear the jar exists within
    APP-INF/lib as expected. n.b. the compile path seams to be okay!
    What am I doing wrong?
    Thanks John

    I can't find the instance I was thinking of, so I might have misremembered that and 'lot' is definitely wrong.
    I did find example where protected inner classes are used though, for example the AccessibleJComponent uses it a lot and another one I used to fix a bug in JTree :
    public class CustomJTree extends JTree {
        @Override
        protected TreeModelListener createTreeModelListener() {
            return new CustomTreeModelHandler();
        protected class CustomTreeModelHandler extends TreeModelHandler {
            @Override
            public void treeStructureChanged(TreeModelEvent e) {
                super.treeStructureChanged(e);
                if(e != null && e.getTreePath() == null) {
                    // the default JTree does not clear the cached expanded paths
                    // when the root is set to null (and event path is null)
                    // Looks this fix did not consider null
                    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4203435
                    clearToggledPaths();
    }

  • How to Disable Event firing while updating a list item using poweshell

    Hi All,
    I am working on a powershell code which updates most of the list items in the entire web application. I am using SystemUpdate($false) to update the items so that 'modified' and 'modified By' and versions are not changed.
    However event receivers gets fired which is now a problem. I want to disable the Event receivers before update and enable it after update. I want powershell code for this. I am using SharePoint 2010.
    Your help would be much appreciated. Thank you in anticipation.
    Regards
    Karthik R.

    hi
    check this thread:
    How to disable event firing outside an event. It contains example on C#, but it is not difficult to convert it to PowerShell.
    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

  • How do I turn on the GUI controls for the Focus Blur Effect in Final Cut Pro X

    I can't find the setting that enables the GUI control overlay to manipulate the parameters of the Focus blur effect in Final Cut Pro X. When I have the clip and the focus effect selected I only get a center element overlay. At one point I had controls for all the other elements of this effect.
    anyone know a shortcut or how I can toggle these controls back on?

    I don't see any other screen controls either.
    Maybe there was a change sometime, or maybe you were using a different effect?

  • Changing default control values in LV application?

    Can anyone help me?
    Is it possible to change default control values in LV program
    programmatically?
    Sergey Yakovlev, Berlin,
    [email protected]

    Its quite complex (in my opinion) to do so programically , but using a set of invoke nodes, you can get it done ('Make this value default'). Look at the attached for info (its a large link name, so you may have to copy and paste in your browser).
    http://zone.ni.com/devzone/devzoneweb.nsf/opendoc?openagent&2C14132F826F839F8625683A000B0B99&cat=DB5863CD70417B07862567930070A058
    I've been simply using config.txt files of read and write to set values.

Maybe you are looking for

  • Power Mac G3 and Monitor

    I turned on my 11 year old G3 and the drive is spinning and it sounds great. However the monitor is illuminated with no desktop. There is no image on the monitor but is illuminated. Does anyone know what is wrong? How can I get back the desktop? I ne

  • Working with standard interface

    I am trying to add audio to a video clip. My problem is this, when I open STP (FCS 2) it opens with the standard interface-audio tracks 1-4 with controls for each track interface has a grey background. When I bring in my video clip the interface chan

  • Probable bug with "Open Resource" (SHIFT_CTRL-R)

    G'day One of the handiest features of Eclipse is "Open Resource" (SHIFT-CTRL-R by default).  It allows one to quickly locate any file in open projects, and open it.  If one has a file name selected in the editor window, it'll even default to finding

  • Program and Source Monitor buttons not working?

    I need to take a screen capture of my project, but NONE of the Program monitor buttons are working. I click them and it doesn't do anything. I'm posting this because none of the suggestions in the other discussions helped me at all. Screen Capture wo

  • Getting error with inserts

    Hi I’ve written a procedure in which I insert rows in respective columns in a table. One column say “TEST” in that table have datatype as varchar2(1024 char) I’ve done 5 unions to accomplish this task. In two blocks, I have written like Primary_key,