Basic thing, but if I create a canvas, set a backdrop and put code in the mouse up event. Nothing happens when I click on it. Is this a bug or am I doing something wrong?
Isn’t this the old trick where you have to return True in the MouseDown event in order fore the MouseUp event to fire
This answers a ton of issues I have trying to get events to fire, I hope a fix is coming.
There is no need for a fix. It is simply the way it is supposed to work.
Read http://documentation.xojo.com/index.php/Canvas.MouseUp and see the note in the green box, smack in the center of the screen
The LR is your friend.
Ok, but my event firing problem (or should I say, non firing of events) has been with the container control I posted a question some time ago, but got no leads on the subject
I am not aware of that particular thread. I was only referring to the MouseUp event. It works that way throughout.
If you create a topic and don’t get a good answer… continue that topic… do not create another one and indicate the problem is the same when this topic never previously mentioned a container control… this topic referred only to MOUSEUP which required (as stated) that MOUSEDOWN must return TRUE
Point taken Dave. I tend to let a subject go if people are not responding. Not responding=no interest=I dont want to bore others to death with my problems. with regard to non-firing events on the container control, I was advised by a contributor that 'contain control events are ‘flakey’ at the best of times . Not being too familiar with the parlance, I assumed that ‘flakey’ meant sporadic.
Sometimes people do not reply simply because they do not know, and that’s better than post inexact things. Sometimes it is because the question is not easy to make out. I do not recall a question about Container Control events not firing, though.
Indeed ‘flakey’ is defined at Dictonary.com as :
In my experience, subject to exceptions of course event on the contrary are quite reliable. Most of the time, when people complain they do not fire, either the event fires and the code is ill formed and somehow does not execute right, or placed in such a way that when the event fires the order of execution is not right. The only way to make sure an event fires (or not) is to place in it something like
system.debuglog "my event" and use the message panel to track what happens in the app. Or the Console for builds.
I had this happen to me once with a settings file I was loading through a module method in App.Open, and somehow default values where wrong. Then I used debuglog to see what was firing and found out that a window open was coming before. I had made the mistake to instantiate the window in my loading method by calling one of its properties. Also sometimes events happen in a counterintuitive way. For instance, control.open happens before window.open. Otherwise, the order of events happening is not guaranteed, and one should not rely on it.
All that to say that events in my opinion are no more flaky than their programmer, but because they happen in a non linear time, they can be confusing.
I am not referring to very real bugs, such as once recently discovered, where a call to Font(FontCount) out of bound blocked subsequent execution . See https://forum.xojo.com/14297-is-this-a-bug-window-opening-not-firing-open-event
The bug will be fixed in 2.1 but in the meantime, the remedy is simply not to go over FontCount-1.
In any case, when you do not get replies right away, what you may want to do is post some details and code. In general, it will pick curiosity at least.
Thats probably the answer right there. I used VB for 20 years and am so set in my ways that its almost like my brain refuses to learn anything new. It took me several years to get my head around the concept of classes. Because VB is a non OOP language (although users claimed that it was a pseudo OOP language), I never really learned about inheritance and sub-classing. For me Xojo is like jumping out of a Lada Niva into a Lamborghini. The basics are familiar, but the rest is an exciting mystery.
Indeed VB is pseudo, where Xojo is the real thing. But because Xojo is relatively simple to use, especially coming from VB, one gets the wrong impression that it is the same. Events are a very real OOP thing : they are encapsulated in time just as well as in code. It takes a bit of adaptation to grasp the whole benefit of event based programming.
I come from VB pre-6, so when I jumped into RB, it was quite a learning experience. For the longest time, I did not use classes and subclasses at all. But by lurking in the forum, and reading books as well as blogs, I finally saw the benefits of it. All that to say that it is possible to get results without using the full power of Xojo, but the more you learn, and the more you appreciate what is available.
The reason it is done this way is because one cannot release the mouse button without pressing it down first and this allows you to add code to the MouseDown event (ex: To check which button was pressed down).
I highly recommend adding code to the MouseUp event to check to make sure the mouse is still inside the canvas as funny things can happen if you don’t. I speak from experience as my current project deals heavily with Canvas and Mouse clicks.
I’ve gone from BASIC --> VB 6 --> RealBasic.
[quote=118185:@Charles Fasano]I highly recommend adding code to the MouseUp event to check to make sure the mouse is still inside the canvas as funny things can happen if you don’t. I speak from experience as my current project deals heavily with Canvas and Mouse clicks.