Override MsgBox with custom method?

Is it possible to override the Xojo reserved ‘MsgBox’ to instead call a method that I wrote that basically just does a ‘System.DebugLog( msg )’?

The reason I need to do this is that I’m using open source code that contains a lot of calls to MsgBox in my OS X app that is a faceless background app, which does not permit MsgBox dialogs to be displayed.

I’d much rather not have to update all of the calls to ‘MsgBox’ in the included open source code included in my app (MacOSLib in this case, plus some of my other code from other projects). Besides being tedious, it’s also prone to being forgotten about when it comes time to update the open source project items.

I created a ‘MsgBox’ method with a global scope and Xojo returns this (reasonable) error message:

“There are several items with this name and it is not clear which one the call refers to”

Any ideas?

Thanks!

rename all your instances of MSGBOX to something like “myMSGBOX”

create a method called myMsgbox with same signature as MSGBOX has

Then do whatever you want in that method. I have a flag in mine… if set I get a msgbox, if not it writes the data to a log

[quote=63519:@Dave S]rename all your instances of MSGBOX to something like “myMSGBOX”

create a method called myMsgbox with same signature as MSGBOX has

Then do whatever you want in that method. I have a flag in mine… if set I get a msgbox, if not it writes the data to a log[/quote]

That’s what I’m trying to avoid doing - renaming all of the instances (calls) of ‘MsgBox’ to ‘myMsgBox’.

Unless I’ve misunderstood you?

no… you understood… only option I see… as you cannot subclass a Msgbox…

Which is probably for the best or else there would be many more debugging challenges if it was possible. :wink:

can’t you search/replace all in one step? Maybe a regex search to only match "MsgBox " at the start of a line.

Search and replace is easy enough to do.

I have considered on a few apps I wrote to replace using msgbox with a custom window that I use in its place. havent dont it yet. would love to hear what your results are.

Scott: That is what I don in all of my apps. I can have different sized fonts as text, set the button captions to what I want. I just call my custom box instead of msgBox. It works fine.