13 Replies Latest reply: May 28, 2009 10:48 AM by flovit88 RSS

Hide and  Shows objects together

flovit88

hello,

I have a graph that works with two input, I would like to show the two input fields only when the graph is open and hide them when the graph is closed. What expression can I use in the Condition to show input fields ?

Many thanks

  • Hide and  Shows objects together
    Neil Miller

    Do you mean maximized/minimized in place of open/closed? If so, you can use the IsMinimized or IsMaximized values in a macro (see the API Guide). There was a previous thread where a similar question came up, but I don't recall if there was more detail than that.

    You could probably use an OnActivate macro for your graph. Then just check if the graph is maximized or minimized (very similar to the API Guide example) and set a variable with the state. Use that variable to hide/show the input fields.

    I also sometimes like to Deactivate the object at the end of an OnActivate macro. That way, if the user does a maximize and minimize without clicking on anything else, it will still work.

    • Hide and  Shows objects together
      flovit88

      Yes, I mean minimized and maximized, but I'd like to it without macro, only with the Show/Always-Conditional of the object's properties...just because I never use macro...but if it's the only way...

      • Hide and  Shows objects together
        Neil Miller

        As far as I know, macros are the only way to determine the state of an object. There are no properties available to an expression that would tell you if the object is maximized or minimized. The macro needed is not too difficult, so if you're looking for a time to write your first macro, this may be it.

        Here's a thought I had from way out in left field, but it may be possible to use a selection to get something like what you want. You could not use the Maximize/Minimize buttons on the chart, but could hide/show the chart based on your selection.

        Add an Inline field (I'll call it Field) to your load with one value (1, Open, whatever). In the Conditional Show of your objects, use something like: GetFieldSelections(Field) = 1. Now, when 1 is selected in your Field, the objects will be visible. If nothing is selected, the objects will be hidden.

        Using something like this would kind of accomplish your task without the use of macros. The downside is that since this is not the common usage of a select box and min/max, the user might have a hard time figuring out what they are supposed to do.

        • Hide and  Shows objects together
          flovit88

          Well, I'm trying macro and I have strange behaviour :

          I have this macro only in the module (see attach text file).

          When I maximized the object CH22, the variable doesn't set to 1, but the object is moving on the seet...at a different place each times...

          What did I wrong ?

          Thanks

           

           

          • Hide and  Shows objects together
            Neil Miller

            I seem to be having issues with IsMaximized. I changed it to an IsMinimized statement and simplified your macro a bit.

            sub openGroupeDate
            set v=ActiveDocument.Variables("openGroupeDate")
            set o=ActiveDocument.GetSheetObject("CH22")

            if o.IsMinimized then
            v.SetContent 1, true
            else
            v.SetContent 0, true
            end if

            o.Deactivate
            end sub

            As you may have noticed, the variable values didn't change. For some reason, IsMinimized is true for this object when the object is Restored. This could probably use some looking in to. If this macro is added as the OnActivate for the chart, it should work.

            I've attached a sample file that shows or hides a text box depending on the state of the chart.

            • Hide and  Shows objects together
              flovit88

              Thanks a lot it works ....almost...

              On your example, when you open the chart and then activate it by clicking on it, the texte disapear...strange.

              • Hide and  Shows objects together
                flovit88

                Hello,

                This subjects is almost close, there is still the last problem, is it a bug ?

                • Hide and  Shows objects together
                  flovit88

                  This is to put the subject on top of the list...

                  • Hide and  Shows objects together
                    Neil Miller

                    Sorry, I somehow lost this thread. I was looking for it for reference and I saw there were still some problems.

                    While building this, I found some inconsistent behavior with the IsMaximized and IsMinimized items. My guess is that when maximizing or minimizing, the OnActivate macro runs before the state change. Therefore, IsMinimized is true when maximizing the item, because it started out minimized. Once you re-activate it, it starts maximized and IsMinimized is false.

                    I can't get IsMaximized to tell me anything. It always seems to be false.

                    In order to try and resolve this issue, I set the macro to a button. When I click the button, the macro will give me the state when using IsMinimized. When using IsMaximized, I still get nothing. I think there has to be a bug with IsMaximized. IsMinimized seems to work, but there appears to be a problem with timing and the OnActivate macro.

                    I'm going to spend some more time on this. I'll post here if I find a solution.

                    • Hide and  Shows objects together
                      Neil Miller

                      I spent a little more time on this this morning and I am convinced that it is not usable.

                      When minimizing an object, the OnActivate macro triggers before the object is actually minimized. Therefore, it seems impossible to have anything happen when an object is minimized. I think some OnMinimize and OnMaximize functions are needed in future versions. You can test this out by adding an OnActivate sub containing a message box to an object. When you try to minimize the object, the box will pop up while the object is still maximized. In this case, it seems impossible to even minimize the object.

                      The IsMaximized flag doesn't seem to do anything. I set up an if...then that set a variable when IsMinimized, IsMaximized or neither. I never got the IsMaximized to fire. It was either IsMinimized or the default.

                      The method I would use instead is to disable the minimize/maximize buttons on the object and use a button to hide/show the objects instead. This eliminates the need to use the OnActivate and IsMinimized items. If you want to get really tricky, you can use transparent buttons to make it seem like the Minimize/Maximize functionality is working. I have attached a sample. There is a transparent button over the minimized object and a transparent button over the minimize button on the maximized object. All of the objects have a Conditional Show. To Hide/Show, we just change the variable.