BevelButton in Cocoa

Hi, guys,

I am trying to do a simple thing that used to work in Carbon very well.

I have two windows (Window1 and Window2). Window1 has a BevelButton with the following code


  if me.Value=true then
    Window2.Visible=true
  else
    Window2.Visible=False
  end

Clicking the BevelButton is supposed to open/hide the Window2.

This works flawlessly in Carbon but in Cocoa it performs each operation (showing the Window2 and hiding the Window2) only once, and than clicking the button stops producing any results.

Any advice?

Thank you very much

Val

Indeed, I can reproduce this.

I submitted a related (?) bug before : <https://xojo.com/issue/28580> but in that bug, the problem was that Window.visible=true wouldn’t work until the end of an event loop.

In your example, it seems to work once, then stops working.

Note: you can try using “window2.show” but that has the effect of showing the window and bringing it to the front which is not what you want I’m guessing.

Tried to work around the glitch hoping that it was a BevelButton problem

Created a property myInteger in Window1. This property stored the number of clicks of the Button (simple push button).

Created a Label that would be displaying the number of clicks.

Then, I put the following code into the Button


  myInteger = myInteger + 1
  
  Label1.text=str(myInteger)
  
  if myInteger mod 2 = 0 then //Divisible by 2, so it is even
    Speak"Even"//Put your code here
    Window2.Visible=False
  else //myInteger is odd
    Speak"Odd"//Put your code here
    Window2.Visible=True
  end if

Clicking the Button incrementally increases the counter but Window2 keeps misbehaving as it did with the Bevel button.

Conclusion - this is a universal Cocoa glitch. Most likely the glitch is with the Window class in Cocoa - in Carbon the code works perfectly.

I hope they fix the bug before they expect me to renew the license.

I think it might be two issues here.
#1 Does the bevel button value ever equal true?
#2 Window2.Visible will actually create or pull or whatever the window.

Try this instead.

if me.Value=true then Window2.Show else Window2.Hide end

There was a bug in previous version of Xojo with Window.visible = true . We had to use Window.show . I don’t know if it’s corrected.

I don’t use (sticky or toggle , I don’t remember which is what), I set myself the value of the bevelbutton:
MyBevelButton.value = True / False
And it works in Carbon and in Cocoa (can’t copy/paste code as I answer from iPad)

Just a thought: You may be able to achieve the same effect by moving the window way off screen and back, instead of making it invisible.

[code]
if me.Value=true then
Window2.top = 300
else
Window2.top = -3000
end

//or whatever[/code]

This bug may have something to do with the difference I spotted when switching to Cocoa , where an invisible canvas stopped giving me mouse events. (I was using one as a splitter. In carbon I made it invisible while dragging around. Under Cocoa, as soon as it went invisible, it stopped ‘listening’)

[quote=39742:@Thomas ROBISSON]I don’t use (sticky or toggle , I don’t remember which is what), I set myself the value of the bevelbutton:
MyBevelButton.value = True / False
And it works in Carbon and in Cocoa (can’t copy/paste code as I answer from iPad)[/quote]
Which you could also do with:

me.value = not me.value

This will toggle the value.

Thank you everybody for the answers.

  1. Showin/Hiding Window2 is an good work around.
  2. Moving Window2 out of the screen is another good way to have it done.

I’ve noticed that with the Show/Hide method the window disappears a little bit slower than with Visible/Unvisible method.

I am just curious why?

Thank you for everybody’s he;lp, and have a wonderful day!

Val

[quote=39802:@VALERIY KOZMENKO]I’ve noticed that with the Show/Hide method the window disappears a little bit slower than with Visible/Unvisible method.

I am just curious why?[/quote]
Waouuuw, how did you see that??? You make it flash hiding/showing lany times?

As the window.visible was buguy, I change my programs to use .hide and .show but I didn’t see the difference. It should be about milliseconds no?

Then just a question more. I’m curious why, like you. But I’m too curious how you see it :slight_smile: .

I could be wrong with the speed of Show/Hide. “The eye sees what the brain knows.”