So looks good. We have hello being drawn in the middle of
our canvas. So what next?
Well, we could do one of two things I guess.
We could I guess we could add an input field here and start trying to read in a
number and then print that number. But let's, let's just break that into two
steps. Let's go a little simpler.
Let's define a kind of constant value. We want to draw in the middle of the
canvas. And get that working with Scott's code.
And the last thing we'll do is add an end into the input field that actually
modifies that value. So I'm going to break that task into
simpler tasks. So I'm going to go through and define a
global value. Let's just say value and we'll say it's, I
don't know, $3.12 and let's go through and get that drawing inside the draw handler,
so how could I do that? I could take value,
Turn that into a string. And I think I would get 3.12 drawn on the
canvas. Let's try that, and see what happens.
Good, good, good, okay. So, values a number.
I stored it in the global variable and now I've actually converted a string and drawn
it on a canvas. Now there is a reason I made it a global
variable. Just wasn't because I wanted to make
everything become variable because I'm going to use that global variable now
inside the input handler. And I'm going to actually essentially
convert whatever I read into the value for that global variable.
So let's go through now and actually go through and do kind of the next step.
Let's go ahead and put the input. Go ahead and put in the thing that
actually recognizes the, the number we want draw.
So let's say. Define input<u>handler What's it take, it's,</u>
it's given some text. What do we need to do? We want to take
that text and we want to convert it onto a floating point number that we can then
draw out on the canvas. So we can say, maybe value = float(text).
So, if we give something that looks like a floating point numbers, flow will convert
floating point number and this is one thing we need to do here, because float is
a global variable. We need to say global value because we're
going to actually assign to and try to change it.
Hm, oh yeah, one more thing, we need to actually go through register that handle.
So since that frame.add<u>input oh, you know what, let's just go in the docs and see</u>
what parameters it takes. I always mess this up.
So let's be a little proactive here and go.
So here we are. Control objects, edit input field.
What does it want? It wants a label, it wants the input
handler and it wants a width, I think I can do that.
So let's go down here, what's the label? Let's say enter value, the handler's going
to be input, handler the width, let's make it 100.