Tabstops in the option menu object

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Tabstops in the option menu object

Post by jalz » Sat Jan 10, 2015 2:00 pm

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

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Tabstops in the option menu object

Post by dave.kilroy » Sat Jan 10, 2015 3:13 pm

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
"...this is not the code you are looking for..."

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Tabstops in the option menu object

Post by jalz » Sat Jan 10, 2015 3:48 pm

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
Attachments
tabstops.png
tabstops.png (16.92 KiB) Viewed 6025 times

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Tabstops in the option menu object

Post by Simon » Sun Jan 11, 2015 12:12 am

Isn't the quick fix to right align column 3?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Tabstops in the option menu object

Post by dave.kilroy » Sun Jan 11, 2015 11:09 am

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

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
Dave
"...this is not the code you are looking for..."

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Tabstops in the option menu object

Post by jalz » Sun Jan 11, 2015 4:02 pm

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
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.

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Tabstops in the option menu object

Post by dave.kilroy » Sun Jan 11, 2015 8:24 pm

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
Attachments
menuexample-tweaked.livecode.zip
(2.55 KiB) Downloaded 188 times
"...this is not the code you are looking for..."

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Tabstops in the option menu object

Post by SparkOut » Sun Jan 11, 2015 10:31 pm

jalz wrote:Sparkout I didn't know you could right align things in a menu
You mean Simon. (Although, just to confuse things even more, my name is actually Simon too)

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Tabstops in the option menu object

Post by jalz » Sun Jan 11, 2015 10:50 pm

:oops: Sparkout, corrected now-must of been reading another response from you on another thread whilst responding to this.

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

Post Reply