Front or Back are not the same

Hi, I joined Xojo yesterday night and I am now almost ready to leave it.

Few words about myself, just to knowm my background.
I started with MS VB last century; in 2006 (if I recall correctly), I tested Real Basic (buying a license) and later Real Studio, abandoned both for a long serie of bugs and difficulties. Yesterday I decided to give another chance to a ‘new’ Basic (when I do not need a GUI, I program in C) and I found Xojo.
As soon I saw the NotePlayer control I managed to build a MIDI keyboard to test it and Xojo in general.

Leaving apart (for the moment **) other small/medium problems and inconsistencies, what really shocked me was the absurd behaviour of Z-Order management, that is:
I made a piano keybord using black and white rectangles, with obviously the black keys OVER (forced by the IDE) the white ones.
A mousedown event get the keys index and produce the note to be played: very simple and effective, but…
clicking a black key gets the index of the underlying white rectangle, the left or the right one depending on which half of the black key was hit.
Between the white keys there is a 2 pixel wide empty space; when I am lucky enough to catch this space I get the correct note…fantastic.

Possibly I did some wrong choice with the controls or there are other reasons that I can not see right now, but if this is the result of my first approach, it is to much for me.

I would appreciate any indication, even that I am stupid (it can be, no problem).
Andrea

**

  • closing the running app (any) from the Menu or from the window checkbox, I get a Window error message caused by ‘Debug(my app).exe’; every time.
  • the Help (this content) tries to open the Language Reference windows which does not exist; in the task bar there is a new icon for this page, but the window never appears.
  • in the layout to duplicate a set of 12 rectangles (1 octave) takes from 10 to 15 seconds

Environment:
Windows 7 SP1 32bit
Intel Pentium Dual Core 3GHz - 4GB RAM
Firewall disabled
Xojo 2016 4.01 (or the last one, anyway)

overlapping controls can cause issues sometimes (but especially with Windows, … the fault of Microsoft more than of Xojo)

As to your bullet items… more information is necessary.

your “rectangles”… what are they? Canvas? Buttons? Custom Class? creating a dynamic control set (which is what I “assume” you are doing, should take a fraction of a second, if done properly)…

What error message? perhaps your CLOSE routine is referring to something in the window (which in turn reinstantiates the window, causing a recursion loop?

Help File… local copy? or remote copy?

Did you remember to return TRUE from the MouseDown event of the black key? If not, the click will be passed through to whatever is beneath it, which is consistent with your description.

Hi Andrea, no, you’re not going crazy with regards to z-order, don’t panic, from what I have worked out so far there are z-order issues in xojo on the windows platform, and contrary to popular belief, they are not Microsoft issues, sorry Dave.

You can read more about my findings here:

https://forum.xojo.com/38658-xojo-framework-z-order-backwards

Xojo have verified my observations in a (https://xojo.com/issue/47001)]Feedback Case #47001 but have yet to report back on it.

In short, you will need to order the items backwards (as xojo is ordering them the wrong way that windows expects) and utilise a piece of code I wrote to implement the correct rendering styles on the controls.

Here is an example project showing the problem and the fix.

https://www.dropbox.com/s/pu5k486xfuffrwa/BugZOrderWithWindowProc.xojo_binary_project?raw=1

The method you are looking for in the code is ZOrderFix.

If you have any problems figuring this out let me know and I’ll try to help.

With regards to the following:

You will need to click right mouse on the task bar icon, move up to select Move then press right arrow on the keyboard once, give the mouse a wiggle and the window should appear. Its just off the screen and there is no code to detect this and place it back onto the screen.

As for the other problems, others may be able to help with those.

Thanks to all for the answers.

[quote]Dave S: …creating a dynamic control set (which is what I “assume” you are doing, should take a fraction of a second, if done properly)…[/quote] Actually I selected the original 12 rectangles (pure and simple rectangles), members of a control set, and did a ‘duplicate’ (ctrl-D). I do not know it this is ‘done properly’.
The required time is a function of number of existing items, at a growing rate of about 5 seconds for each new group. Adding a new group of 12 members to the existing 49 takes around 21 seconds.

By the way, is there any chance to avoid the online debugging (I presume) of my program ? It conflicts with my Zone Alarm suite and force me to close it.

[quote]Tim Hare: Did you remember to return TRUE from the MouseDown event…[/quote]Absolutely not! GREAT, it fixed the problem, thanks.
Now the question becomes: where in the infinite User Guide is explained it ? Is it mandatory to return a true/false in any event handler? If not, in which ones? I’m used to return a boolean only from a function call in C.

[quote]: You will need to click right mouse on the task bar icon, move up to select Move then press right arrow on the keyboard once, give the mouse a wiggle and the window should appear…[/quote] Julian, fortunately the Z-order problem was depending on a different situation, as said above.
For the Language Help: I forgot to make also a three counterclockwise turns around the chair singing Uhu, Uhu Uhu :slight_smile:
I don’t know how you discovered this ‘simple’ operation, but it did the job., thanks for your suggestion

I will give another chance to Xojo, until the next unexplainable situation, at least.

The side effect of the z-order issue in xojo on windows is the situation you describe. Clicking through a control and hitting the control “behind it”. My code fixes the problem, I suggest you try it out or at least watch the video here:

https://www.dropbox.com/s/38llc0c7md5h0tk/ZOrderProblem.mp4?raw=1

On the video, when the mouse is over the red rectangle it clicks through to the black rectangle, much like your explanation of the keys on a keyboard problem.

I’ll leave it up to you if you want to try the code, I know it works though.

Good luck.

The ones that have a return value? If an event handler returns a boolean (some do, some don’t), there’s a reason for it. That should be explained in the Language Reference manual / online documentation for that event. Sometimes, the reason is stated something like “Return True to indicate that you have handled the event.” That statement indicates that if you don’t return true, the event will probably be propagated along some hierarchy. If that hierarchy isn’t self-evident (it may be explained in the User Guide), just drop a line on the forum and somebody will explain.

Some common events:
MouseDown - All controls, in Z-order, then the Window
KeyDown - the control with focus, then the Window, then the App (note, however, that some controls such as TextField, consume all normal keystrokes and don’t pass them on)
Menu Actions / Keyboard Shortcuts - the control with focus (controls can have menu handlers), then the Window, then the App

Hope that helps.

Thanks Tim, the reason to return (sometimes) a boolean is clear.
What is not clear (at least for a newbie like me - with Xojo!) is why the documentation, that I am only now able to read, does not show immedately that an event expect a retuning value. Possibly I am used to other documents that tell something like:
Boolean MouseDown(X as Integer, Y as Integer, Button as …)
In my, poor, opinion if a function intercepts (consumes) an event, this should not bubble unless specifically declared, not the other way.

Anyway…
This is now my 3° day spent in experiments with Xojo, with alternating feelings: in some moment I’m excited by the rich set of controls and functionalities, and by the easyness of have something happens with few lines of code.
In other moments I’m highly disappointed by the ‘fragility’ of the GUI.

Yesterday night I made some minor modification (added for sure 2 labels and one placard) to a working test App; I had the Language Reference window open too, if it interest.
As soon as I launched the program I got the Windows error message telling that XOJO.exe (not my app) had an error and will terminate.
Closing this message XOJO exited to window.
My app is still there but it is totally unusable since if I tried to open it, the above cycle restarts.

Another fact:
sometimes, all controls on the windows disappear, leaving only the caption (when present); I can still select each control, but only the sizing handles are visible. Since there is not any Redraw command, I played around until I discovered that maximazing the program window the controls return visible.

Now: am I particularly unlucky? Is my environment not adeguate? or the program was not tested enough under Windows (or Win7)?

[quote=320757:@Andrea Agassi]Thanks Tim, the reason to return (sometimes) a boolean is clear.
What is not clear (at least for a newbie like me - with Xojo!) is why the documentation, that I am only now able to read, does not show immedately that an event expect a retuning value. Possibly I am used to other documents that tell something like:
Boolean MouseDown(X as Integer, Y as Integer, Button as …)[/quote]

It does
See this page in the web based docs http://documentation.xojo.com/index.php/PushButton.MouseDown
And the same page in the local docs shows

<see below>.MouseDown ( x as Integer, y as Integer ) As Boolean
It just doesn’t use the same syntax you’re expecting where the return value is listed first (like in C)
Thats NOT Xojo syntax

Its last - the “As Boolean” part

If you expect Xojo to act like VB (same syntax, same UI layout for the IDE, etc, etc, etc) and that certain commands that appear “common” will do the exact same thing as in VB (like DoEvents) then you will be constantly disappointed
While they share some similarities they are not the same tool nor do they work the same way

I can’t really speak to the current version, but it seems like the last year or so, the Windows version has been a little unstable. For good reasons, of course. Big changes to the Windows version. But you might want to go back to 2015r4.1 if you can.

[quote=320760:@Norman Palardy]If you expect Xojo to act like VB (same syntax, same UI layout for the IDE, etc, etc, etc) and that certain commands that appear “common” will do the exact same thing as in VB (like DoEvents) then you will be constantly disappointed
While they share some similarities they are not the same tool nor do they work the same way[/quote]
Norman, you are right. Possibly I was urging to discover the new ambient and I miss some important points.
In my partial defense I wish to note that without the initial problems with the documentation and, mainly, without the repeating problems with the GUI, my feeling and approach would have been much better.

Now instead it is rock stable :slight_smile: , maybe !

Well, I will have the next days to find something new.
I’m currently trying to implement a Terminal Console to interface my last electronic project (which is the reason for my use of a Visual Basic (ops…I did not intended that!)