Tabstops in the option menu object
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Tabstops in the option menu object
Hi Guys,
I have a pop up menu(option) and it populates values using database records. The menu is built with 3 fields, the length of the second field varies massively from 10 characters to 30 characters and I would like all columns to be tabbed equally. I know i can use tabstops to align tabbed data in a field, is it possible to do the same for popup menus? Ive tried it and cant get it to work, so is it possible or another command to do this?
Many thanks as always
Jalz
I have a pop up menu(option) and it populates values using database records. The menu is built with 3 fields, the length of the second field varies massively from 10 characters to 30 characters and I would like all columns to be tabbed equally. I know i can use tabstops to align tabbed data in a field, is it possible to do the same for popup menus? Ive tried it and cant get it to work, so is it possible or another command to do this?
Many thanks as always
Jalz
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Tabstops in the option menu object
Hi Jalz - sorry but a bit mystified as to what you are trying to do. Do you want to change alignment in an option menu or are you working with tab panel? Can you give some more information, or ideally a screenshot of the problem and what you want to achieve?
Kind regards
Dave
Kind regards
Dave
"...this is not the code you are looking for..."
Re: Tabstops in the option menu object
Hi Dave,
I'll attach a screenshot. I'd like the third column aligned in my option menu. I've looked at the option menu property and tabstops does not exist so I'm assuming there is no way of aligning 3 columns "easily" - thought I would ask though. If you or anyone else knows a way to do this, would really appreciate it.
Thanks
Jalz
I'll attach a screenshot. I'd like the third column aligned in my option menu. I've looked at the option menu property and tabstops does not exist so I'm assuming there is no way of aligning 3 columns "easily" - thought I would ask though. If you or anyone else knows a way to do this, would really appreciate it.
Thanks
Jalz
- Attachments
-
- tabstops.png (16.92 KiB) Viewed 6031 times
Re: Tabstops in the option menu object
Isn't the quick fix to right align column 3?
Simon
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Tabstops in the option menu object
Hi jalz
I could only make it work by using the formattedwidth property of chunks inside a field, others may give you an improved solution. Try the following code: I assume three fields (fldData1, fldData2, fldData3) to act as containers for string values that come from your database, and one field (fldDisplayText) to work on the text and display the finished result
Dave
I could only make it work by using the formattedwidth property of chunks inside a field, others may give you an improved solution. Try the following code: I assume three fields (fldData1, fldData2, fldData3) to act as containers for string values that come from your database, and one field (fldDisplayText) to work on the text and display the finished result
Code: Select all
on formatText
put 0 into tFormattedWidth
put fld "fldData2" into fld "fldDisplayText"
lock screen
repeat with tLineNum = 1 to (the number of lines in fld "fldDisplayText")
if the formattedwidth of line tLineNum of fld "fldDisplayText" > tFormattedWidth then put the formattedWidth of line tLineNum of fld "fldDisplayText" into tFormattedWidth
end repeat
repeat with tLineNum = 1 to (the number of lines in fld "fldDisplayText")
put the formattedwidth of line tLineNum of fld "fldDisplayText" into tFormattedWidthString
repeat with tFiller = tFormattedWidthString to (tFormattedWidth )
if the formattedwidth of line tLineNum of fld "fldDisplayText" < tFormattedWidth then
put space after line tLineNum of fld "fldDisplayText"
else
exit repeat
end if
end repeat
put line tLineNum of fld "fldData1" & tab & line tLineNum of fld "fldDisplayText" & tab & line tLineNum of fld "fldData3" into line tLineNum of fld "fldDisplayText"
end repeat
unlock screen
end formatText
"...this is not the code you are looking for..."
Re: Tabstops in the option menu object
Hi Dave,
Thank you very much for your example. I'll try and workout how to implement it in my menu example. Simon I didn't know you could right align things in a menu, that might be the easier thing.
I've attached a file of how my menus are generated just so you can see what Im trying to do.
Thanks
Jalz
Thank you very much for your example. I'll try and workout how to implement it in my menu example. Simon I didn't know you could right align things in a menu, that might be the easier thing.
I've attached a file of how my menus are generated just so you can see what Im trying to do.
Thanks
Jalz
- Attachments
-
- menuexample.livecode.zip
- (1.41 KiB) Downloaded 194 times
Last edited by jalz on Sun Jan 11, 2015 10:41 pm, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Tabstops in the option menu object
hi jalz - I've tweaked your stack by folding in my formatText handler
I'm suggesting that you populate your menu button on opening the card or during some event prior to the menu being clicked (to give time for communication with the database & formatting to take place).
So on opening the stack click the 'populate menu' button and then click the menu to see it formatted as normal, then click the 'format menu' button and try clicking the menu again.
I've separated out what happens so you can more easily follow how it works but when you come to use it properly it could all happen in one handler and the fields I use could be hidden.
Is this the kind of thing you are after?
Dave
I'm suggesting that you populate your menu button on opening the card or during some event prior to the menu being clicked (to give time for communication with the database & formatting to take place).
So on opening the stack click the 'populate menu' button and then click the menu to see it formatted as normal, then click the 'format menu' button and try clicking the menu again.
I've separated out what happens so you can more easily follow how it works but when you come to use it properly it could all happen in one handler and the fields I use could be hidden.
Is this the kind of thing you are after?
Dave
- Attachments
-
- menuexample-tweaked.livecode.zip
- (2.55 KiB) Downloaded 188 times
"...this is not the code you are looking for..."
Re: Tabstops in the option menu object
You mean Simon. (Although, just to confuse things even more, my name is actually Simon too)jalz wrote:Sparkout I didn't know you could right align things in a menu
Re: Tabstops in the option menu object

Dave, thank you for your modified stack, I'll dissect it and learn from it. Think this will solve the problem I have.
Best wishes
Jalz