How do you instantiate a Toolbar in code?

  1. ‹ Older
  2. 4 months ago

    Norman P

    Jun 10 Pre-Release Testers, Xojo Pro great-white-software.com/blog
    Edited 4 months ago

    There are a lot of controls you cannot add on the fly like you're trying to do
    You cant just run

       dim pb as new PushButton
       // .. other code here to somehow get the pushbutton added to the windows control list (which is not a property)

    Toolbars re not alone in this regard

    Some of this is forced on Xojo by the various OS level frameworks
    Some imposed on us because of how the Xojo frameworks work

    Basically you cant get them initialized and set up so that events are handled properly etc,

    The other thing is that with Windows you cannot inherit the user interface.
    So if you create a Window that has a toolbar on it you cant use that Window as the base class for other windows an inherit the existing layout.

    Writing the same code to edit and listtables over & over in multiple copies of the same window would seem to violate your own previous post

    Someone smarter than myself Anytime we must type the same code more than once, we should think about abstraction

    At most make 2 windows that you can configure to edit / list ANY table instead of creating multiple copies

  3. Edited 4 months ago

    @Norman P First off I would not create 250 windows to edit tables
    I'd have one windows which could edit any table and one that could lost any table - 2 windows in total
    And be able to open multiple instances of these windows so if I need to edit or list more than one table at a time I can

    I agree... and perhaps my 250 number was a bit of an exaggeration but even if I only have 2 resources to edit, it feels strange to have to write the same code in the ContentsChanged event handler for both of them.

    I also considered the same strategy as you propose here... and I think it would work fine for the ListWindow as columns can easily be added in code... but how would you create a window that could edit any table? How would you handle an EditWindow in which the presentation of fields needs to be tailored to each object? For example, a simple UserEditWindow might only have four or five fields but a more complex object might have 20 or more fields... organized in tabs... and related lists. For basic edit windows, we might get away with using a generic EditWindow but I'm not sure how it could work for all of them.

    Personally, I think that there is a time and a place for abstraction but the crafting of the user interface is not one of them.

    Building each window individually seems like the best way but even the best of us resort to writing a program to write our programs. (ie: ARGen, StormORM) To me, the entire idea of Active Record goes against the very philosophy of Xojo... but that's a topic for a different thread.

    <rant>

    Nope. Sorry. I hold Xojo to a higher standard than this. The original promise of Real Basic was programming 'for the rest of us'. It promised native, built-in controls that you could arrange in the IDE and then 'wire up' with basic code. Instead, I'm having to subclass everything and 'roll my own' with complex code (if anyone even mentions a 'declare'... I swear... ) in order to build even the most basic of business applications. Where is the DateControl? How about an EmailField that validates format... or an IntegerField or CurrencyField? These are low hanging fruit and yet there is a PasswordField?!

    The DataControl was poorly implemented but genius in it's original conception. Why deprecate it? Why not modernize it? The binding of layout controls to database columns was a great idea but no one has 'flipped' through records with 'next' and 'previous' buttons since HyperCard.

    It's no wonder to me why new Xojo users give up. I've tried and failed with Xojo more times over the past 20 years than I care to admit. I've bought the books, I've watched videos... I even subscribed to the magazine... and yet each time I get a little beyond Eddie's Electronics, I get tripped up with what seem to be obvious omissions in the IDE. API 2.0 sounds like a great start but it's going take a lot more than renaming some functions.

    </rant>

  4. Emile S

    Jun 10 Europe (France, Strasbourg)

    @Kristin G Active Record

    https://en.wikipedia.org/wiki/Active_record_pattern

  5. @Emile S https://en.wikipedia.org/wiki/Active_record_pattern

    Yes. Thank you. I'm fully aware of what Active Record is and it is a great idea for an environment such as PHP where you might use MVC... but Xojo wasn't built that way. We shouldn't have to use AR in Xojo. Why would I go and type all my field names a second time into a class that describes my object? The window itself should do that. It has a text field for each property into which I can add validation, store the value, and until recently... bind it to a column in a database.

  6. Norman P

    Jun 10 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    Sounds like what you want is "Filemaker with more low level coding capability"
    Or Access

  7. @Norman P Sounds like what you want is "Filemaker with more low level coding capability"
    Or Access

    Was that not the original vision of Realbasic?

    "Programming for the rest of us"

  8. Jean-Yves P

    Jun 10 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    @Kristin G Yes. Thank you. I'm fully aware of what Active Record is and it is a great idea for an environment such as PHP where you might use MVC... but Xojo wasn't built that way. We shouldn't have to use AR in Xojo. Why would I go and type all my field names a second time into a class that describes my object? The window itself should do that. It has a text field for each property into which I can add validation, store the value, and until recently... bind it to a column in a database.

    I did it for my apps, making a database editor app, that copies windows items from the database definition, and paste it in the xojo ide. took me some time to build it, but now it works fine and gives me a lot of flexibility in programming database windows.

  9. Norman P

    Jun 10 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    @Kristin G Was that not the original vision of Realbasic?
    "Programming for the rest of us"

    In many ways I would say it is true - just not in the way you're imagining
    Its not writing C/C++/Obj-C/Java which IS the norm

    I have literally been using it since before version 1.0 shipped in 1998 and I dont recall it ever having been presented or promoted as what you envision which seems more like Filemaker/Access but with a lot lower level coding ability when needed

    Thats not to say it couldnt have components that make that kind of work easier.
    Just that they dont

  10. @Norman P I have literally been using it since before version 1.0 shipped in 1998 and I don't recall it ever having been presented or promoted as what you envision

    From the User Guide ...

    Welcome to Xojo, the easiest tool for creating your own apps. Xojo is made up of a rich set of graphical user interface objects, a modern object-oriented language, an integrated debugger, and a multi-platform compiler. Together they make up the Xojo Integrated Development Environment or IDE.

    With the IDE, you can build your app's interface simply by dragging and dropping interface objects onto the apps’s windows and dialogs. In this QuickStart, you will see how easy it is. Xojo provides you with all the tools you need to build virtually any app you can imagine.

    You'll have to forgive me if I imagined an app more complex than Eddie's Electronics.

  11. Norman P

    Jun 10 Pre-Release Testers, Xojo Pro great-white-software.com/blog
    Edited 4 months ago

    "build the interface" - not "build your app"

    Maybe that should say "layout your interface" instead of "build your interface" so you dont get fooled into thinking that building the interface IS how you build the entire app

    Xojo is not a zero-code tool
    Never has been and has never been sold as such

    Its just not Xcode, interface builder etc

    FWIW the IDE is built using Xojo

  12. @Norman P "Xojo is not a zero-code tool. Never has been and has never been sold as such

    I never expected zero code but is it not the goal of a 'RAD' application to reduce the amount of code necessary? Xojo's own website claims to have Native Controls that allow you to quickly build your interface. Isn't a date picker part of the interface?

    I remember that one of the big complaints about RB from VB users was the lack of available controls and pre-built code compared to what they were used to. At the time, I assumed that RB would eventually catch up but it's been 20 years and we still only have TextField and PasswordField.

    Far be it for me to say what Xojo should be or shouldn't be but as an ex-FMP developer and someone who has struggled to master Xojo over the years, if the goal is to provide RAD to casual programmers, yeah... we could do with a bit more FileMaker.

  13. Julian S

    Jun 10 Pre-Release Testers, Xojo Pro UK

    I might be missing something obvious has I've not read every word of this thread, but why don't you have a container control for each "table view" then just use embedwithin to dynamically pull in the container relating to the table you're currently viewing? You can then have your primary window with your toolbar and your containers with have the logic for each "view" and with a simple bit of code to dynamically alter the toolbar buttons relating to each container?

  14. Norman P

    Jun 10 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    @Kristin G I never expected zero code but is it not the goal of a 'RAD' application to reduce the amount of code necessary? Xojo's own website claims to have Native Controls that allow you to quickly build your interface. Isn't a date picker part of the interface?

    I'm the wrong person to ask
    I dont work there or speak for them

    You should address this to @Geoff P

  15. @Julian S I might be missing something obvious has I've not read every word of this thread, but why don't you have a container control for each "table view" then just use embedwithin to dynamically pull in the container relating to the table you're currently viewing? You can then have your primary window with your toolbar and your containers with have the logic for each "view" and with a simple bit of code to dynamically alter the toolbar buttons relating to each container?

    I had considered this. I'm not saying 'no'... I just wish that I had a RAD tool that didn't make me jump through such hoops.

    Thanks for the input. It is appreciated.

  16. Bob K

    Jun 10 Pre-Release Testers, Xojo Pro, Third Party Store Kansas City
    Edited 4 months ago

    @Kristin G] Isn't a date picker part of the interface?

    I've been part of the community for close to 18 years. There are two controls that practically everyone wants day one: Date Picker and a Grid Control. For the former I'd recommend going to Einhugur. For the latter I'd recommend using the PiDog DataView control (to be fair, the Listbox is quite powerful but it's not out-of-the-box powerful.

    It is *sad* that these controls are not part of Xojo since, as you said, Xojo's website claims to have native controls to quickly build your interface. I wonder how many developers skip Xojo because it doesn't have a native Date or Grid control?

  17. Michel B

    Jun 10 Pre-Release Testers, Xojo Pro RubberViews.com

    Kristin, no offense, but you seem to be mentally pretty rigid about what you expect Xojo to be.

    Since I started back in 1982, I programmed in several languages, and each of them have limitations.

    Right now, I use another language than Xojo to develop an Android app. There are limitations to it, but instead of blaming the conception, I use imagination and try to make due.

    About imagination, precisely, just run the attached project. It should satisfy what you were after. On Mac, it adds a toolbar dynamically very nicely.

    DynamicToolbar.xojo_binary_project

  18. @Michel B Kristin, no offense, but you seem to be mentally pretty rigid about what you expect Xojo to be.

    No offence taken, sir. I'm not sure that 'rigid' is the correct term though. I have certain expectations about what Xojo is supposed to be based on the marketing... but perhaps I'm wrong about that and I need to reset my expectations?

  19. Markus W

    Jun 10 Pre-Release Testers #JeSuisHuman New Zealand, Auc...
    Edited 4 months ago

    @Kristin G No offence taken, sir. I'm not sure that 'rigid' is the correct term though. I have certain expectations about what Xojo is supposed to be based on the marketing... but perhaps I'm wrong about that and I need to reset my expectations?

    Expectations lead to disappointment. Disappointment leads to anger. Anger leads you to the Dark Side …

    ;)

  20. James D

    Jun 10 Pre-Release Testers, Xojo Pro Europe (Switzerland)

    @Kristin G I had considered this. I'm not saying 'no'... I just wish that I had a RAD tool that didn't make me jump through such hoops.

    Thanks for the input. It is appreciated.

    Out of interest how many other RAD tools have you used to build full blown application? Every RAD tool I have ever used had one thing in common - they do not allow you to do things your way! You need to follow the philosophy of the tool to be successful.

    In an app I’m working on at present I have around 10 different container controls that are used to edit and display data from about 300 tables. They interact with the main window via a set of events and a common interface. Events are used to get the main window to enable buttons on the toolbar for importing or exporting data etc and the main window calls methods on the common interface to cause the container to refresh the data and so on. I understand this is a common approach in XOJO to do solve this problem.

    At the end of the day you will have to decide if you are going to go with the philosophy of the RAD tool you select, XOJO or something else, or opt for an all purpose language and acceptance the associated drop in productivity.

  21. @James D You need to follow the philosophy of the tool to be successful.

    I could not agree more! Perhaps I misunderstood what the Xojo philosophy was?

  22. Newer ›

or Sign Up to reply!