# App logic

* Click on the `Blocks` tab.

{% hint style="success" %}
The **Blocks tab** allows you to write block codes. You can access all of your palettes or components inside the Blocks tab.
{% endhint %}

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FSf6yUTKfVKa0ioShQVUm%2FScreenshot%202025-03-24%20124401.png?alt=media&#x26;token=08975b8d-c2b8-4d98-88cb-1478ae5c8290" alt=""><figcaption></figcaption></figure>

* Click on the `Button1` component and drag and drop `when Button1 click` block.

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2F1GaJjlW0LWlDzrjSJ6MA%2FScreenshot%202025-03-24%20124726.png?alt=media&#x26;token=48321359-32fb-47ee-9969-afd1426199dc" alt=""><figcaption></figcaption></figure>

* From `Control` , drag and drop a `if` block

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2F55XSVYpK8oUo8ZOhlRwD%2FScreenshot%202025-03-24%20125024.png?alt=media&#x26;token=8e551952-a84f-4be3-9a41-2cd6218baa4a" alt=""><figcaption></figcaption></figure>

* Click on the gear icon on the `if` block and drag and drop a `else`  block inside the `if` block

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FnpQFwqvQTEcYuJbepR7L%2FScreenshot%202025-03-24%20125239.png?alt=media&#x26;token=9bf22c1a-e308-4368-a7a4-cc231dcb8d40" alt=""><figcaption></figcaption></figure>

* From `Logic`  block, find the equality testing operator and connect it with the `if`&#x20;

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FbZIU1fAVW2IJmvlntoXa%2FScreenshot%202025-03-24%20125355.png?alt=media&#x26;token=7933b44c-0334-4090-ac5d-62e62fa54f49" alt=""><figcaption></figcaption></figure>

* Click on the `Button1` and find a block called `Button1.Text` , drag and drop it on the first jigsaw puzzle box.

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FgM6atyt1Jyonqr1zbAJU%2FScreenshot%202025-03-24%20125806.png?alt=media&#x26;token=1d4ad72f-781d-443e-a9c0-d901966a3c93" alt=""><figcaption></figcaption></figure>

* In the next jigsaw box, drag and drop an empty text from the `Text` block, and type `Hide`  The text should match with your button text.

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FgKcO3v9dZPJs2LIes5lK%2FScreenshot%202025-03-24%20130038.png?alt=media&#x26;token=46cd4923-42c9-4081-8d0e-7c2bc38a3d1b" alt=""><figcaption></figcaption></figure>

* Click on the `Image1` block and drag and drop a block called `set Image1.Visible` , from  `Logic` , drag and drop the `false` block and connect it with the `set Image1.Visible` block

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FM91myf67WsYnLN1XDbmi%2FScreenshot%202025-03-24%20130206.png?alt=media&#x26;token=9e4196e0-3916-4cef-9c68-506f246fed8a" alt=""><figcaption></figcaption></figure>

* Click on the `Button1` block and locate the block `set Button1.Text` , drag and drop the block below the previous block and connect a `Text` block with the text `Show`&#x20;

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FNWzbbj1MK8q1MTfznTOq%2FScreenshot%202025-03-24%20130552.png?alt=media&#x26;token=b712b1f3-31e7-465a-ab84-a881a8081c81" alt=""><figcaption></figcaption></figure>

* Right click on the `Set Image1.Visible` block and duplicate it. Move the duplicated block inside the `else` block and change `false` to `true`

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FEnKWNRfMONqakRBqccbW%2Fimage.png?alt=media&#x26;token=e5dd69c9-7262-4db5-bf7b-03226d00a708" alt=""><figcaption></figcaption></figure>

* Right click on the `set Button1.Text` block and duplicate it. Move the duplicated block inside the `else` block and change `Show` to `Hide`&#x20;

<figure><img src="https://4150609950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagfmHwJEF69bMnbybhxL%2Fuploads%2FJetIr7zkKenilXumQd69%2Fimage.png?alt=media&#x26;token=d04a27b1-5c67-4841-af2d-de77373ec9c0" alt=""><figcaption></figcaption></figure>
