realbasic-nug
[Top] [All Lists]

Re: Subclassing toolbutton / toolitem ?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Subclassing toolbutton / toolitem ?
From: Norman Palardy <npalardy at great-white-software dot com>
Date: Fri, 29 Jun 2007 12:54:58 -0600
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <F35287D1-C62E-45F7-9DD9-9E847DE17EC1 at great-white-software dot com> <14E1840C-1E9C-409A-AC80-723F8AA7B873 at bradrhine dot com>
On 29-Jun-07, at 12:36 PM, Brad Rhine wrote:

> It was a while back, but I remember running into some trouble with
> subclasses ToolItems. What are you trying to accomplish?

I just have different buttons that present different menus of  
different kinds of objects.
But, to populate these menus I need to add items to them. The items  
are stored in one big list of classes and I can determine what type  
each item is.
So I figured I create a subclass of ToolButton and call one  
"myTypeA_ToolButton", another one "myTypeB_ToolButton" etc

Eventually I'd like to let people rearrange the items in the toolbar  
(I'll build it on the fly)

Then as I iterate through the list of items I have that need to be  
presented in the menus for each button I could do something like -  
this is only email ready code for illustrative purpoes :)

   // add each item to the right button's menu
   for i as integer = 0 to ubound(listOfClasses)
        select case true
          case listOfClasses(i) isA TypeA
              for j = 0 to toolbar.Count - 1
                if toolbar.item(j) isA myTypeA_ToolButton
                     // add this item to the menu for this button
                end if
             next       
          case listOfClasses(i) isA TypeB
                if toolbar.item(j) isA myTypeB_ToolButton
                     // add this item to the menu for this button
                end if

          case listOfClasses(i) isA TypeC
                if toolbar.item(j) isA myTypeC_ToolButton
                     // add this item to the menu for this button
                end if

        end select
   next

Once the menu is created that's not a problem because I can test each  
item tag in the menu with IsA to see what type it is and behave  
accordingly

For now I test the NAME of each toolbutton

> Maybe there's a workaround...

I just identify them by name but subclasses should work


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>