Desktop ComboBox causes App to hide on switch to other App

Desktop, & Xojo 2023r1.1
I don’t know if this is just a Mac problem.
This problem happens in a specific way and apparently only my machine has this particular ComboBox feature. I posted this problem awhile ago and nobody else had it. In order to get the control to open I have to click twice. If I just click on it once, and switch to another App my App is hidden behind every other window.
This doesn’t happen predictably but rather randomly.
I suppose I could put in FocusLost something, but what?
Any suggestions?

I bet there’s something up with your keyboard and that one of the keys (probably CMD) is sticking.

Sorry. This is only is with the mouse. It works perfectly with the keyboard.

While I understand your logic here, I still think it’s worth looking into. You see… holding down a modifier key (I can’t remember if it’s Opt or CMD now) when clicking on another app can cause your current app to hide. Just like holding down the CTRL key will get you a contextual click with the left button. It certainly could be that this key works correctly when you’ve just been typing, but that it slowly drifts down into a “contact” position when you leave it alone.

I’ve seen several weird things with keyboard failures over the years with my macs, and if I were having that problem, I’d be reaching for my spare just to eliminate it as a possibility.

Aah. I understand your thinking, and I will look into it.

That would be the Option key, but if it really was stuck down, typing would produce alternate characters. IMO, I don’t think it’s the actual cause.

Hi @Arthur_Gabhart

Is there a simple project that replicates the issue and you can post here so we can get a better idea?

Sorry, but I’m not interested because I did a project and people said they couldn’t see it. I would otherwise.
(being repetitive) I would like to know how to prevent it from being hidden. Just to clarify, when the focus is on the ComboBox and I go to a different App, my App is pushed all the way to back and the only way I can find it is by minimizing all to the other windows.

Yes, holding down the Option key while clicking another app will hide the current app. But this would apply to every app.

Can you link to the project you did? I’m sure a few of us would be happy to check it out.

1 Like

I finally got the project small enough to not be complex, but it only appears when you have more code than what I have. I would like someone to look at my ComboBox and tell me if it performs correctly. The last time I tried to show the problem, it wouldn’t work.
What happens is it takes at activation 2 clicks for the box to drop down. To make the display switch from Read-Only to editable: Cmd-e for Mac and Ctrl-e

I will not be surprised if it doesn’t work like I said.

https://www.dropbox.com/scl/fi/uvtwhs49dac6nwx5mjax9/CmboBox.xojo_xml_project?rlkey=4sq0pugrd8x9a00i0zns75jxf&dl=0

Thanks for the demo project. Here’s what I did:

  • opened project in 2023 R3 and tried to run it. There were 2 missing pictures (which I substituted with dummy pictures)
  • added
    system.DebugLog CurrentMethodName
    to all focusLost & focusReceived events
  • ran the app, started clicking around.
  • I can not see any issues with other apps hiding, however…
  • I can see the problem where you have to click twice to get the comboBox to drop down, as shown in this video:

I figured it out. What I did:

  • I could reproduce this easily by clicking in CREdit field, then clicking the GRMCboBox dropdown arrow.
  • so I put a breakpoint in CREdit.focusLost
  • I then commented out various parts of the code to see what was triggering the bug
  • its these lines:
If CREdit(index).Text.IsEmpty = False Then 
  If index = kCHmWd Then
    tWTst = New WTest( me.Width, me.Height, False, True, CREdit(index).Text, self, index )
    tWTst.Close
    App.FinFieldSize( CREdit(index).Text, Self, me, index, True)
[...]
  End if
End If// CREdit(index).Text.IsEmpty = False Then

For some reason in this code, you are creating then immediately closing a new window WTest .

Opening a new window will generally give focus to the new window, so it’s perfectly logical that your comboBox dropdown is losing focus and closing when you do that.

Solution: Don’t Do That :grinning:

Edit to add: This was on macOS Ventura 13.6

Thank you, and I think that solved my original problem.

1 Like