Resizing field, graphic and group together
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Resizing field, graphic and group together
Hi All,
I am back again with the resizing questions.
This time I am resizing a field, a graphic and a group at the same time.
This is the basic idea:
I have a field with a height of 44, a graphic with a height of 58. Both of them belong to a group with a height of 66.
When the end-user types into the field, the heights of the field, the graphic and the group become bigger.
This is what I have up until now:
on rawKeyDown
put the height of me into theight
put the height of graphic "cause1" into theightgr
put the height of group "Causa1" into theightgroup
if the formattedheight of me > the height of me then
set the height of me to theight + 20
set the height of graphic "cause1" to theightgr +20
set the height of group "Causa1" to theightgroup +20
end if
if the formattedheight of me <the height of me then
set the height of me to theight -20
set the height of graphic "cause1" to theightgr -20
set the height of group "Causa1" to theightgroup -20
end if
pass rawKeyDown -- let the keystroke be processed normally
end rawKeyDown
It works, but not exactly the way I want to.
I dont know how to set up the minimum height. I tried with
set the minHeight of me to 44
I also tried with the property inspector (geometry > limit object)
Also, using on rawKeyDown, is not the best option, because the height af all my objects change continuosly.
Finally, I want to align in the middle the graphic and the field with an image inside the group. How can I script it? I have aligned them using the property inspector. But once the end user insert the text, I dont know how to aligned them again.
Any ideas?
Thanks a lot,
Marta
I am back again with the resizing questions.
This time I am resizing a field, a graphic and a group at the same time.
This is the basic idea:
I have a field with a height of 44, a graphic with a height of 58. Both of them belong to a group with a height of 66.
When the end-user types into the field, the heights of the field, the graphic and the group become bigger.
This is what I have up until now:
on rawKeyDown
put the height of me into theight
put the height of graphic "cause1" into theightgr
put the height of group "Causa1" into theightgroup
if the formattedheight of me > the height of me then
set the height of me to theight + 20
set the height of graphic "cause1" to theightgr +20
set the height of group "Causa1" to theightgroup +20
end if
if the formattedheight of me <the height of me then
set the height of me to theight -20
set the height of graphic "cause1" to theightgr -20
set the height of group "Causa1" to theightgroup -20
end if
pass rawKeyDown -- let the keystroke be processed normally
end rawKeyDown
It works, but not exactly the way I want to.
I dont know how to set up the minimum height. I tried with
set the minHeight of me to 44
I also tried with the property inspector (geometry > limit object)
Also, using on rawKeyDown, is not the best option, because the height af all my objects change continuosly.
Finally, I want to align in the middle the graphic and the field with an image inside the group. How can I script it? I have aligned them using the property inspector. But once the end user insert the text, I dont know how to aligned them again.
Any ideas?
Thanks a lot,
Marta
Re: Resizing field, graphic and group together
Marta,
I attach a stack below. I don't know if it is exactly what you want. I guessed a little from your previous resizable group. If it is not what you want you could upload a stack with just the group you are working on and it will be a little clearer. You have to zip the stack before you upload it.
regards
Bernd
I attach a stack below. I don't know if it is exactly what you want. I guessed a little from your previous resizable group. If it is not what you want you could upload a stack with just the group you are working on and it will be a little clearer. You have to zip the stack before you upload it.
regards
Bernd
- Attachments
-
- adjustFieldHeightDynamically.rev.zip
- (1.55 KiB) Downloaded 281 times
Re: Resizing field, graphic and group together
Hi Bern,
Thanks a lot. That is exactly what I need. I am not working anymore with the resizable oval, but the field text does exactly what I want
Marta
Thanks a lot. That is exactly what I need. I am not working anymore with the resizable oval, but the field text does exactly what I want

Marta
Field size
Hi again,
I keep working with the size of the field and I need some help.
My field can be bigger than 150. The problem is that this does not allow the user to "move" within the field and make some changes in, let's say, the first line of the field. Adittionally, it seems that, despite the message, it creates more lines if the user presses the return key. I have tried to add to the code the keys user are allowed to press (delete keys, arrows), but again, this seems not to do exactly what I want
So, what I did looks more or less like this:
if (tMyformaHeight > 150) and (thekey is not 32) and (thekey is not 65288) then
set the height of me to tMaxHeight
answer "you have reach the limit."
end if
I have also tried limiting the number of lines, but I have no idea how to "lock" the field size (height and width) while allowing the users to do some changes in the content.
Any idea?
Thanks,
Marta
I keep working with the size of the field and I need some help.
My field can be bigger than 150. The problem is that this does not allow the user to "move" within the field and make some changes in, let's say, the first line of the field. Adittionally, it seems that, despite the message, it creates more lines if the user presses the return key. I have tried to add to the code the keys user are allowed to press (delete keys, arrows), but again, this seems not to do exactly what I want

So, what I did looks more or less like this:
if (tMyformaHeight > 150) and (thekey is not 32) and (thekey is not 65288) then
set the height of me to tMaxHeight
answer "you have reach the limit."
end if
I have also tried limiting the number of lines, but I have no idea how to "lock" the field size (height and width) while allowing the users to do some changes in the content.
Any idea?
Thanks,
Marta
Re: Resizing field, graphic and group together
Marta,
I don't really understand what you want:
What is the max height of your field? is it 150? or bigger?
Do you want to disallow what exactly?
Do you what to block the return key so that no empty lines are in the field?
65288 is the delete key is that the key you want to block?
I don't understand what you say about editing. If you are using the field script that I posted then I dont have difficulties editing it.
Maybe you might want to post just this field object and the surrounding graphic that you use now and explain what the user should be allowed.
regards
Bernd
I don't really understand what you want:
What is the max height of your field? is it 150? or bigger?
Do you want to disallow what exactly?
Do you what to block the return key so that no empty lines are in the field?
65288 is the delete key is that the key you want to block?
I don't understand what you say about editing. If you are using the field script that I posted then I dont have difficulties editing it.
Maybe you might want to post just this field object and the surrounding graphic that you use now and explain what the user should be allowed.
regards
Bernd
Re: Resizing field, graphic and group together
Hi Bern,
Thanks for your answer. Let's see if I can explain better what I need.
So, I have this field inside a rectangular graphic, and I need them to become bigger as the user enters text, but I also need to limit how big and how small the field can be.
This is my code as right now:
The problem I have is that, as soon as it gets to the maximum height (150) the message appears even if the user is only at the beginning of the line. If you click "ok" you still can type some letters, but after a couple of them the message appears again.
The desired outcome would be that the user cannot add more lines, but that (s)he can type up until the end of the line, and that (s)he can make changes to what (s)he has already typed.
Any ideas on how to get that?
Marta
Thanks for your answer. Let's see if I can explain better what I need.
So, I have this field inside a rectangular graphic, and I need them to become bigger as the user enters text, but I also need to limit how big and how small the field can be.
This is my code as right now:
Code: Select all
on rawKeyUp thekey
put the topLeft of grc "cause1" of the owner of me into tCause1TopLeft
put the height of me into theight
put the topLeft of me into tMyTopLeft
put the formattedHeight of me into tMyFormatHeight
put 32 into tMinHeight -- adjust min height
put 150 into tMaxHeight --adjust max height
lock screen
--First, make field bigger
if (tMyFormatHeight > the height of me) then
set the height of me to tMyFormatHeight -- adjust
set the height of graphic "cause1" of the owner of me to tMyFormatHeight + 10
end if
--Control that field is not too big
if (tMyFormatHeight > 150) and (thekey is not 32) and (thekey is not 65288) and (thekey is not 65362) and (thekey is not 65364) and (thekey is not 65363) and (thekey is not 65361) then
set the height of me to tMaxHeight
set the height of graphic "cause1" of the owner of me to 160
answer "Has alcanzado el limite de caracteres permitido. Revisa el texto y borra algo si quieres anadir algo mas."
pass rawkeyUp
end if
--Control that field is not too small
if tMyFormatHeight < 32 then
set the height of me to tMinHeight
set the height of graphic "cause1" of the owner of me to 42
end if
if (tMyFormatHeight <the height of me) and (the height of me > tMinHeight) then
set the height of me to tMyFormatHeight -- adjust
set the height of graphic "cause1" of the owner of me to tMyFormatHeight + 10 -- adjust
end if
unlock screen
pass rawKeyUp -- let the keystroke be processed normally
end rawKeyUp thekey
The desired outcome would be that the user cannot add more lines, but that (s)he can type up until the end of the line, and that (s)he can make changes to what (s)he has already typed.
Any ideas on how to get that?
Marta
Re: Resizing field, graphic and group together
Hi Marta,
try this:
this is not bulletproof, e.g. a user types inputs new text after the maximum height is reached and the lines break. If you want to catch that a little more coding is involved.
But have a look at this and tell me if it is what you want and if it is good enough for your situation.
regards
Bernd
try this:
Code: Select all
local sNoGoChars = false
local sIntercept = "65293," -- add keys you want to block in a comma delimited list here
on rawKeyUp thekey
put the topLeft of grc "cause1" of the owner of me into tCause1TopLeft
put the height of me into theight
put the topLeft of me into tMyTopLeft
put the formattedHeight of me into tMyFormatHeight
put 32 into tMinHeight -- adjust min height
put 150 into tMaxHeight --adjust max height
lock screen
--Control that field is not too big
if (tMyFormatHeight > 150) then
set the height of me to tMaxHeight
set the height of graphic "cause1" of the owner of me to 160
if not sNoGoChars then
answer "Has alcanzado el limite de caracteres permitido. Revisa el texto y borra algo si quieres anadir algo mas."
end if
put true into sNoGoChars
exit rawkeyUp
end if
--First, make field bigger
if (tMyFormatHeight > the height of me) then
set the height of me to tMyFormatHeight -- adjust
set the height of graphic "cause1" of the owner of me to tMyFormatHeight + 10
put false into sNoGoChars
end if
--Control that field is not too small
if tMyFormatHeight < 32 then
set the height of me to tMinHeight
set the height of graphic "cause1" of the owner of me to 42
put false into sNoGoChars
end if
if (tMyFormatHeight <the height of me) and (the height of me > tMinHeight) then
set the height of me to tMyFormatHeight -- adjust
set the height of graphic "cause1" of the owner of me to tMyFormatHeight + 10 -- adjust
put false into sNoGoChars
end if
unlock screen
end rawKeyUp thekey
on rawKeyDown pKey
-- check if max height is reached and block certain keys
if sNoGoChars = true then
if pKey is among the items of sIntercept then
beep
exit rawKeyDown
end if
end if
pass rawKeyDown
end rawKeyDown
But have a look at this and tell me if it is what you want and if it is good enough for your situation.
regards
Bernd
Re: Resizing field, graphic and group together
Marta,
I tried to do a script that checks for overflow of the text and contains it.
please test this and tell us if it works. I tested and think it works, but....
regards
Bernd
I tried to do a script that checks for overflow of the text and contains it.
Code: Select all
local sReachedMax = false
local sIntercept = "65293,65421" -- add keys you want to block in a comma delimited list here, now it is only the return & enter key
local sOldHTML, sNoOfLines, sOldNoOfLines, sSelChunk, sOldSelChunk
on rawKeyUp thekey
put the topLeft of grc "cause1" of the owner of me into tCause1TopLeft
put the height of me into tHeight
put the topLeft of me into tMyTopLeft
put the formattedHeight of me into tMyFormatHeight
put 32 into tMinHeight -- adjust min height
put 150 into tMaxHeight --adjust max height
lock screen
--Control that field is not too big
if (tMyFormatHeight > tMaxHeight) then
set the height of me to tMaxHeight
set the height of graphic "cause1" of the owner of me to 160
if not sReachedMax then -- the first time
answer "Has alcanzado el limite de caracteres permitido. Revisa el texto y borra algo si quieres anadir algo mas."
put true into sReachedMax
put (the number of lines of the formattedText of me) into sOldNoOfLines
if last char of me is cr then add 1 to sOldNoOfLines -- if last char is a return then it is not counted as line
put the HTMLText of me into sOldHTML
put the selectedChunk into sOldSelChunk
exit rawKeyUp
else
send checkOverFlow to me in 0 milliseconds
exit rawKeyUp
end if
end if
--First, make field bigger
if (tMyFormatHeight > tHeight) then
set the height of me to tMyFormatHeight -- adjust
set the height of graphic "cause1" of the owner of me to tMyFormatHeight + 10
put false into sReachedMax
put empty into sMaxLines
end if
--Control that field is not too small
if tMyFormatHeight < tMinHeight then
set the height of me to tMinHeight
set the height of graphic "cause1" of the owner of me to 42
put false into sReachedMax
put empty into sMaxLines
end if
if (tMyFormatHeight < tHeight) and (tHeight > tMinHeight) then
set the height of me to tMyFormatHeight -- adjust
set the height of graphic "cause1" of the owner of me to tMyFormatHeight + 10 -- adjust
put false into sReachedMax
put empty into sMaxLines
end if
unlock screen
end rawKeyUp thekey
on rawKeyDown pKey
-- check if max height is reached and block certain keys
if sReachedMax = true then
if pKey is among the items of sIntercept then
beep
exit rawKeyDown
end if
end if
pass rawKeyDown
end rawKeyDown
on checkOverFlow
if sReachedMax then
put the HTMLText of me into sHTML
put the number of lines of the formattedText of me into sNoOfLines
put the selectedChunk into sSelChunk
if sNoOfLines > sOldNoOfLines then
set the HTMLText of me to sOldHTML
select sOldSelChunk
beep
exit checkOverFlow
end if
put sHTML into sOldHTML
put sSelChunk into sOldSelChunk
end if
end checkOverFlow
regards
Bernd
- Attachments
-
- adjustFieldHeightDynamicallyIII.rev.zip
- (1.99 KiB) Downloaded 322 times
Re: Resizing field, graphic and group together
Hi Bern,
I am still trying to understand some parts of the code, but the good news is that it seems to work just the way I want it. The only minor detail, that I am not sure if I can or even I want to fix, is that it allows the user to move the field horizontally by pressing the space key, but as soon as the try to type a letter, it goes back to the "normal" work area.
Thanks a lot
Marta
I am still trying to understand some parts of the code, but the good news is that it seems to work just the way I want it. The only minor detail, that I am not sure if I can or even I want to fix, is that it allows the user to move the field horizontally by pressing the space key, but as soon as the try to type a letter, it goes back to the "normal" work area.
Thanks a lot
Marta
Re: Resizing field, graphic and group together
Marta,
I tried this and it seems to work: add a local variable at the top
than replace the on rawkeyDown handler with this:
this blocks if there are more then 3 spaces in a row and beeps. Adapt if necessary. At least it prevents the user from doing funny things with spaces...
regards
Bernd
it is a little tricky what is going on. The formattedText of a field is the field as it appears on screen with a return on each line break. Regardless of whether it was an automatic line break or a return. That way you can determine if the number of visible lines changed. The htmlText of a field is the text of a field with its format (bold, text size etc.) That is the "undo" if there is too much overflow. That is way you can restore the text as it was before the overflow. Actually what is confusing, or confused me/took me a while to figure out, was this undo function.mtecedor wrote:I am still trying to understand some parts of the code
I see what you mean. I did not test for that. Funny that Rev does not break a line if there are just spaces. If it is going to be a problem then on could probably trap for say two/three spaces in a row and prevent further spaces.mtecedor wrote:The only minor detail, that I am not sure if I can or even I want to fix, is that it allows the user to move the field horizontally by pressing the space key, but as soon as the try to type a letter, it goes back to the "normal" work area.
I tried this and it seems to work: add a local variable at the top
Code: Select all
local sMaxSpaces = 0
Code: Select all
on rawKeyDown pKey
-- check that not more than 3 spaces in a row are typed
if pKey is 32 then
add 1 to sMaxSpaces
if sMaxSpaces > 3 then
beep
exit rawKeyDown
end if
else
put 0 into sMaxSpaces
end if
-- check if max height is reached and block certain keys
if sReachedMax = true then
if pKey is among the items of sIntercept then
beep
exit rawKeyDown
end if
end if
pass rawKeyDown
end rawKeyDown
regards
Bernd
Re: Resizing field, graphic and group together
WAW!!!
That really made it. Thanks a lot, Bernd. As I said, I was not even gonna try it
Marta
That really made it. Thanks a lot, Bernd. As I said, I was not even gonna try it
Marta