How do I make a dynamic text window?

Get help using Construct 2

Post » Sun Jul 02, 2017 5:08 pm

I am trying to make a simple feature. The idea is you click a button and then you click and drag the mouse to create a box to type in, just like in any image editing software. I have currently made this: https://drive.google.com/file/d/0Bxfvxf ... sp=sharing (didn't know how else to put the image)

Once I run the code everything looks fine. I click the button the sprite follows the mouse but after I click and drag the box doesn't appear (and yes I have forgotten to set it to visible but I did that while writting this and it still didn't work). So how do I do it?
B
6
Posts: 12
Reputation: 276

Post » Sun Jul 02, 2017 9:33 pm

It is Mouse.X - posX and Mouse.Y - posY. TextBox cant have a negative size.

But i dont see a simple way to reset the Boolean in that flow.
'On Button CLICKED' will steal a 'On Mouse button released'.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jul 02, 2017 10:18 pm

99Instances2Go wrote:It is Mouse.X - posX and Mouse.Y - posY. TextBox cant have a negative size.

But i dont see a simple way to reset the Boolean in that flow.
'On Button CLICKED' will steal a 'On Mouse button released'.


So I should use a On Button Pressed on both? I tried that and it still didn't work but I will try it again to be 100% certain.
B
6
Posts: 12
Reputation: 276

Post » Mon Jul 03, 2017 11:57 am

99Instances2Go wrote:It is Mouse.X - posX and Mouse.Y - posY. TextBox cant have a negative size.

But i dont see a simple way to reset the Boolean in that flow.
'On Button CLICKED' will steal a 'On Mouse button released'.


Ok so I re-wrote part of the code because I forgot to save :roll: and it now looks like this :

https://drive.google.com/file/d/0Bxfvxf ... sp=sharing

When I run the code and click the button the cursor changes correctly. After that I click and drag but from what I understand an infinite loop takes place and everything just lags and firefox crashes. If I moved the actions from the While statement to the disabled (to the Is Checked sub-event) then the textbox appears where I want it to and scales depending on the mouses position just like intended but even if I let go of the mouse button it still scales with it and never lets go.
B
6
Posts: 12
Reputation: 276

Post » Mon Jul 03, 2017 7:48 pm

Based on the first selfie, this is what you try, or very close to.
https://www.dropbox.com/s/a28b1xucic0op ... .capx?dl=0

The second selfie makes no sense to me.

About the While loop. The events run in a loop already. Use any other loop only if you want an iteration to happen inside 1 tick. If you update graphics in a loop, and therefor inside the time of 1 tick, you will never see them updating, besides there where the loop ended, because the drawing happens at the end of every tick. Hence the term 'Frame Depended'.

About the 'and never lets go'. The text-box that you draw is 'in focus'. Meaning, it is stealing the mouse. A text-box is a form element. It does not live inside the canvas. It lives on top of the canvas in its own world. Basically canvas and form elements are different windows. If you have two windows on your desktop, the one that is in focus is getting keyboard and mouse changes. The other dont.

Just disable the object, so it can not switch to 'in focus'.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Jul 08, 2017 8:46 pm

99Instances2Go wrote:Based on the first selfie, this is what you try, or very close to.
https://www.dropbox.com/s/a28b1xucic0op ... .capx?dl=0

The second selfie makes no sense to me.

About the While loop. The events run in a loop already. Use any other loop only if you want an iteration to happen inside 1 tick. If you update graphics in a loop, and therefor inside the time of 1 tick, you will never see them updating, besides there where the loop ended, because the drawing happens at the end of every tick. Hence the term 'Frame Depended'.

About the 'and never lets go'. The text-box that you draw is 'in focus'. Meaning, it is stealing the mouse. A text-box is a form element. It does not live inside the canvas. It lives on top of the canvas in its own world. Basically canvas and form elements are different windows. If you have two windows on your desktop, the one that is in focus is getting keyboard and mouse changes. The other dont.

Just disable the object, so it can not switch to 'in focus'.


Ok so after a bit of time of rework after rework I made this which...half works. It works perfectly sometimes other times the textbox doesn't leave focus so if a mistake of some sort could be pinpointed that would be appreciated.

Img: https://drive.google.com/file/d/0Bxfvxf ... sp=sharing

I personally think its the "On button released" part but I don't know of a way around it.
B
6
Posts: 12
Reputation: 276

Post » Sun Jul 09, 2017 8:21 am

99Instances2Go wrote:Just disable the object, so it can not switch to 'in focus'.



As i told you.
Set the property 'enabled' (in the layout) to 'no'.
After the full creation sequence (including scaling), use the action .. TextBox > Set enabled.



If you going to draw boxes on top on each other, then use my example.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jul 09, 2017 1:41 pm

99Instances2Go wrote:
99Instances2Go wrote:Just disable the object, so it can not switch to 'in focus'.



As i told you.
Set the property 'enabled' (in the layout) to 'no'.
After the full creation sequence (including scaling), use the action .. TextBox > Set enabled.



If you going to draw boxes on top on each other, then use my example.


So I replaced the "Set unfocused" with "Set enabled" -> "Disable" and it still has that effect where some times it works and others it doesn't. I tried it with both and still same result. It seems to me that the "On Button Released" part sometimes doesn't get activated when I release as not only does it not get disbled but neither unfocused. Problem is I have no idea why. As for your code I don't know if it works on the 245 stable release since I had to download another release to open it.
B
6
Posts: 12
Reputation: 276


Return to How do I....?

Who is online

Users browsing this forum: Bootfit, Huemerson, jorgmaquoi and 5 guests