Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Oct 23, 2017 9:10 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Toolbar Extenders
PostPosted: Thu Jul 12, 2012 6:04 am 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
I got a little tired of the convoluted mess my code was becoming when working with toolbar items, so I made this handy little module that should hopefully make working with them easier.. Everything is in a set/get pair of methods..

Here is an example of setting the caption using the built-in methods
ToolButton(MyToolbar.item(0)).Caption = "hello world"


and an example with the extender
MyToolbar.ItemCaption("itemName") = "hello world"

where "itemName" is the name of the toolbar item

Find it on my site http://shaosean.tk/
It is completely free and in the public domain.. I wash my hands of it ;-)

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Thu Jul 12, 2012 7:05 am 
Offline

Joined: Sun Feb 19, 2006 4:00 pm
Posts: 1282
Location: Heidelberg, Germany
Nice, but why do you cast in your example?

MyToolbar.Item( 0 ).Caption = "hello world"

would do.


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Thu Jul 12, 2012 12:12 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Did you try that code? Toolbar.Item returns a ToolItem, not a ToolButton. ToolItem does not have a Caption property. Casting is necessary for most of the properties you care about.


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Thu Jul 12, 2012 1:26 pm 
Offline

Joined: Sun Feb 19, 2006 4:00 pm
Posts: 1282
Location: Heidelberg, Germany
Yes, I did. Autocompletes with caption.


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Thu Jul 12, 2012 1:53 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
Indeed it does autocomplete with .caption and it indeed does update the caption of the toolbar item.. According to the docs, it shouldn't work.. Is this a bug or an undocumented feature? ;-)

But regardless, I still think it is easier to work with the toolbar items based on their name instead of their positioning in the toolbar as this allows you to move them around without breaking your code..

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Last edited by shaosean on Thu Jul 12, 2012 1:56 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Thu Jul 12, 2012 1:56 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Then things have changed since I last fiddled with toolbars. I'm pleasantly surprised.


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Thu Jul 12, 2012 2:26 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
My bad.. I forgot an "Assigns" in the ItemEnabled setter, so just replace that method with this one (or add "Assigns" to the pEnabled parameter)

Sub ItemEnabled(Extends pToolbar As Toolbar, pItemName As String, Assigns pEnabled As Boolean)
for i As Integer = 0 to (pToolbar.Count()- 1)
if (ToolButton(pToolbar.Item(i)).Name = pItemName) then
ToolButton(pToolbar.Item(i)).Enabled = pEnabled
exit for i
end if
next
End Sub

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Thu Jul 26, 2012 11:19 am 
Offline
Site Admin
User avatar

Joined: Fri Sep 30, 2005 9:35 am
Posts: 987
Location: South Portland, Maine
shaosean wrote:
Indeed it does autocomplete with .caption and it indeed does update the caption of the toolbar item.. According to the docs, it shouldn't work.. Is this a bug or an undocumented feature? ;-)

Seems like a documentation bug to me. I've updated the Language Reference so that Caption (and Tag) are now properties of ToolItem.

_________________
Paul Lefebvre
Developer Evangelist
Xojo, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Sun Jul 29, 2012 7:18 am 
Offline

Joined: Mon May 31, 2010 5:35 am
Posts: 2412
Location: Netherlands
If you have more extentions to classes, please let me know.
I can put them inside the DutchTools module and maintain a wiki for it.

It's located on GitHub. You can share them with me or place them as suggestion on the Tips forum here.
I'll be watching this forum about every day (as usual).

You can download my classes FREE under the MIT license here:
https://github.com/sworteu

_________________
SWORT™
- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion
- REAL Studio Enterprise(latest) and WEB Edition(latest)
- Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins)
For Dutch User Groups ask me to enter!


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Sun Jul 29, 2012 4:15 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
Thanks for the link swort.. I noticed that you posted about using the MIT license (no idea what that is), but I just thought I would let everyone know that I release my code in to the public domain - no licenses, no restrictions, no forced sharing of source code, etc..


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar Extenders
PostPosted: Mon Jul 30, 2012 11:59 am 
Offline

Joined: Mon May 31, 2010 5:35 am
Posts: 2412
Location: Netherlands
shaosean wrote:
Thanks for the link swort.. I noticed that you posted about using the MIT license (no idea what that is), but I just thought I would let everyone know that I release my code in to the public domain - no licenses, no restrictions, no forced sharing of source code, etc..


Well a MIT license is a license for free usage.
http://opensource.org/comment/935

_________________
SWORT™
- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion
- REAL Studio Enterprise(latest) and WEB Edition(latest)
- Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins)
For Dutch User Groups ask me to enter!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group