Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Jun 19, 2018 11:09 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: enable/disable webtoolbar button in code
PostPosted: Sat Jan 05, 2013 9:14 am 
Offline

Joined: Tue Aug 28, 2012 3:52 am
Posts: 28
Hi,

I tried to enable a disabled webtoolbar button in code. What seems logical to me:

if useraction() then
mainToolbar.ItemAtIndex(1).Enable = True
end if


or following Realbasic logic:

if useraction() then
mainToolbar.Button(1).Enable = True
end if


Unfortunately, it doesn't work.

Do you have to find the correct button via enumeration? If so, why do you have to find the correct button via Item.Name in case of a
sub ButtonAction(Item as WebToolbarButton)
if item.name = "copyButton" then
doThisaction()
end if


This doesn't sound logical to me.

Thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: enable/disable webtoolbar button in code
PostPosted: Tue Jan 08, 2013 10:25 am 
Offline
User avatar

Joined: Mon Nov 29, 2010 7:01 pm
Posts: 446
I grabbed this code from one of my projects and it works fine

dim trainingButton as WebToolbarButton = webtoolbarbutton(me.ItemWithName("ButtonTraining"))
if trainingButton <> nil then trainingButton.Enabled = TRUE


Obviously use "Toolbar1." or whatever instead of "me." if you want to call this outside of the toolbar itself. Also make sure to call this in a shown event rather than an open event if that's where you want it.


In the buttonAction event I enumerate with a Case statement, it's easier and cleaner

Select Case item.Caption //or item.Name - whatever you want to go off of.
Case "Home"

Case "Blah


Case "Blee"

Else
msgbox("this button has not been prgrammed to be handled yet.")
End


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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