A lot of times when you need to create a menu at runtime you don’t know the number of items and those items may require some additional data to be handled correctly like a folder item, window reference etc. And in cases like this a subclass of MenuItem makes sense so you can add properties to the subclass and implement the action event to handle that extra data.… Read the rest
Much ado about bevel buttons
One of the things that transitioning from the old Classic framework, which was based on Carbon and HIToolbox, to Cocoa brought about was changes to lots of controls. Bevel buttons fall into that boat and now with the support of Dark Mode they look awful – because bevel buttons are based on an old style control that has no modern equivalent in 64 bit Cocoa.… Read the rest
If you ever need to crash
No. Not at my place 😛
Sometimes you NEED to test your app and whatever remediation you have put in place and need a reliable way to make your app crash
Here it is
Dim p As ptr p.Byte(0) = 123
Those two lines. Insert them anywhere you might put normal code and book your app will crash.… Read the rest
Let the compiler help you
An interesting question posed by a relatively new user came up on the forums. It had to do with how the Array() function worked and how he could force it to return an array of variants to call his method.
His method was defined like
BuildMenu( base as menuitem, params() as variant)
And he would call it like
Result = BuildMenu (base, Array ("Run", False, "Edit", "Rename", "Delete") )
and this would build up a menu from the base item and append menu items to it.… Read the rest
Speed tip with popupmenus
In a different forum a user reminded me of a speed tip that had cropped up once or twice over the years. It has to do with popupmenus.
Basically on older versions of macOS if you did
PopupMenu1.ListIndex = -1 For i As Integer = 0 To 1000 PopupMenu1.AddRow Str(i) Next
This behaved not so badly although there is a slightly faster variation
But on Mojave this is noticeably slow.… Read the rest
A new take on listbox resizing
Normally a listbox doesnt support much in the way of live resizing of rows or columns if you dont have a header row.
Turns out that for something else I’m working on I needed to be able to resize things and NOT have a header row – and also make it possible to resize rows as well by clicking & dragging.… Read the rest
Handy Mojave utility
If you’re a developer and work in light and dark modes and switch back and forth all the time this is a handy utility to grab.
It makes switching between the two modes fast and simple.
Fun things to do with Xcode
I know a lot of you don’t want to mess with Xcode BUT there are some really handy things it can help you with and you don’t have to write any Swift or Objective-C code.
Since you can drop a plist into Xojo to supplement or replace certain keys at some point you may need to create one.… Read the rest
Keep your code off of my controls
Suppose you are creating a new container control to encapsulate some functionality onto this new control. You’re already thinking about “encapsulation” which is a good thing.
Why, when you create this new container, would you then make all the controls on it public so code outside the container can change it ? That seems like it would be a good way to ruin the encapsulation you’re trying to achieve.… Read the rest
Picking a good name
Not for your children (although that is important too since kids can be incredibly harsh and will pick on kids with names that they think sound different or odd)
This is to do with naming methods, properties, and just about everything else in your Xojo projects.
A good name indicates a number of things to anyone who reads the code.… Read the rest