Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1114027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:56:48+00:00 2026-05-17T02:56:48+00:00

I’m working on a toolbar type application. My current plan is to create a

  • 0

I’m working on a toolbar type application. My current plan is to create a “toolbar” class and a “button” class. The toolbar class would create an instance of the “button” for each item on the toolbar. Each instance of the “button” class would handle its button’s GUI events (Mouse Over, Click, etc). I also want to have global options that would affect how these GUI events are handled (highlite in a certain color on mouse over, etc). My problem is that I’m not sure how to let each instance “know” what the current values are for the global options.

What is a good way to handle this? One thought I have is to create an “Options” class, create a single instance of it in the main toolbar class, and then pass a reference to the button class in its the constructor.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:56:49+00:00Added an answer on May 17, 2026 at 2:56 am

    Collecting all options in an Options class, per se, is quite OK.

    If the buttons need to know for other reasons which toolbar they’re in, they’ll keep a reference (for reference read “pointer” in C++, in case it needs to be reseatable;-) to their parent toolbar, and a simple read-only accessor in the toolbar class to return the reference/pointer to the shared options object would be nicer from many points of view (e.g., the ability to rapidly switch from one set of options to another by just switching the one pointer [[or reference]] in the toolbar).

    But if buttons don’t otherwise need any reference to their creator toolbar, I wouldn’t add one (a circular dependency if the toolbar also needs to keep references to the buttons) just for this purpose.

    Rather, if you’re sure “there can be only one” (all buttons in all toolbars use the same options), a static method in the toolbar class (again, with the simple purpose of returning the reference to the “one and only” options object) would suffice.

    I do like the idea of “going through the toolbar” (with a regular method or a static one, depending) rather than forcing each button to add the amount of state needed to separately refer to the “one and only option object”. Of course, a Singleton pattern is another similar alternative (e.g. via a static method in the Options class), but I have some antipathy for that DP as a matter of principle, so I’d rather “go through the toolbar”…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.