• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Check if object is hidden or showing with javascript

Explorer ,
Jun 09, 2022 Jun 09, 2022

Copy link to clipboard

Copied

Hi all.

I'm wondering if anyone knows of a way to check if an object in captivate is hidden or showing, using javascript?

I know I can show/hide using cp.show(objId);

But I want to check if an object is already showing or hiding.

 

Views

555

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jun 09, 2022 Jun 09, 2022

You can do it with this script:

 

cp.model.data.SmartShape_2c.effectiveVi;

 

The bold text is the name of the element you want to check. You must append the "c" to the name of the element.

Votes

Translate

Translate
Community Expert ,
Jun 09, 2022 Jun 09, 2022

Copy link to clipboard

Copied

The easiest way is also to have a variable assigned a value of 1 or 0 depending on the object's condition. That way you can check the value of the variable as part of an advanced action. For example, I frequently assign variables to button clicks in my Captivate projects so I can determine if the learner has pressed all the buttons in an interaction. Here is an example of what I'm talking about. https://www.youtube.com/watch?v=BItqVz3OfGE 

Paul Wilson, CTDP

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2022 Jun 09, 2022

Copy link to clipboard

Copied

Thanks for the reply, but this won't work in my case.

This is a tamplate-page that will be duplicated and the content (images, text, sound) swapped out by others than myself. I need to know at the start of the page, at runtime, how many buttons are visible ... and I don't know the exact ID. I just have them stored in a nodelist.
Stagprimes solution will work though 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 09, 2022 Jun 09, 2022

Copy link to clipboard

Copied

This question came up a short while ago.

You can see my response to that post using the link below.

https://community.adobe.com/t5/captivate-discussions/how-do-you-know-if-an-object-is-hidden-with-jav...

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

Thank you!

I did look before I posted, but didn't find that one.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 09, 2022 Jun 09, 2022

Copy link to clipboard

Copied

You can do it with this script:

 

cp.model.data.SmartShape_2c.effectiveVi;

 

The bold text is the name of the element you want to check. You must append the "c" to the name of the element.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

Thanks for the answer.

I'll try this and stagprimes solution ... just to learn both 🙂

I have both the canvas object and the object stored in a nodelist.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

Thanks for the replies.

It's not that easy javascripting when there is no place to look up available variables and functions.

Just thought I'd post the output of my tests. 

Context: I'm making templates, and in this assignment, there wil at the end appear max 4 buttons (click here to learn more about this type buttons). It's built so the page can be duplicated, and you can change the content, but all functonality will stay the same. When we use the template, I decided to simply turn of the visibility of the buttons we are not to use. So now I can loop through the buttons, check the visibility and only show/activate the buttons that were visible from start.

 

//Get all the response-buttons - I know there is max 4 and that their name/ID begins with "analyze_RespBtn_"
var analyze_allRespBtns = document.querySelectorAll("[id^='analyze_RespBtn_']");

 

//Just to test – Check the visibility of the first object in the node list (it's the canvas-object)
var justTesting1 = cp.model.data[analyze_allRespBtns[0].id].effectiveVi;
var justTesting2 = cp.D[analyze_allRespBtns[0].id ].visible;

 

Output if object is not visible:
justTesting1 = 0
justTesting2 = true

 

Output if object is visible:
justTesting1 = 1
justTesting2 = 1

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

LATEST

The difference between mine and StagPrimes is that "effectiveVi" will show the actual visibility. If the element is hidden initially with the eyeball in the properties or if it is hidden with a hide action.

 

The "visible" will always return true or 1, unless the element it is turned off with the action "hide"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources