Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Hide and Shows objects together

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

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I agree that this doesn't seem possible without an external trigger like a button. Once you click on the object and the macro runs, you can minimize and maximize and many times as you want, and it won't execute the macro again.

In your example, you need to put the buttons in the top layer. Otherwise, if you click on the chart, it will move in front of the button, and everything will stop working.

View solution in original post

13 Replies
Not applicable
Author

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.

Not applicable
Author

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

Not applicable
Author

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.

Not applicable
Author

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

Not applicable
Author

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.

Not applicable
Author

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.

Not applicable
Author

Hello,

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

Not applicable
Author

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

Not applicable
Author

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.