Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Username Password: Remember me

zzz_mousefilter V1.0, adds some useful functions
(1 viewing) (1) Guest

TOPIC: zzz_mousefilter V1.0, adds some useful functions

Re: Move objects with Shift pressed+Mousemove 6 years, 5 months ago #463

  • Lynxx
  • OFFLINE
  • Moderator
  • Java/C#-Developer
  • Posts: 223
admin wrote:

The event that is passed to eventFilter is the specific QxxxEvent and in that sense (in languages like javascript) you can call event.SpecificMethod() without first having to cast it. At least that was the impression I had. Now it's a mystery to me why, for example, when the event is of type "GraphicsSceneMouseMove" you cannot access the method pos() through the event.

event.SpecificMethod() doesn't exists, neither does specificMethod ..
event.inherits(QGraphicsSceneMouseEvent) doesnt work (inherits undefined)

There is a bug in the event-handling it seems, maybe it's wrong to return false all the time, i tried return object.eventFilter(object, event); and return QObject.eventFilter(object, event); and lots others .. which none fixed the problem, you can test the bug with this:
tool = mainWindow.addToolBar("Test"); test = tool.addAction("");
new QErrorMessage().showMessage((test==undefined?"undefined":test.toString()));


You will notice when the eventfilter is installed you will get "undefined" and Physion will crash when closing the application. If the filter is not loaded you get "QAction".
Infinity is vast, especially near end.
bye, Lynxx
Last Edit: 6 years, 5 months ago by Lynxx.

Re: Move objects with Shift pressed+Mousemove 6 years, 5 months ago #474

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
Yes it's strange.

When the event filter is installed you get 'undefined' otherwise you get a QAction.

Returning 'true' if the specific cases where you're 'consuming' the event may solve it. I am not sure...

Re: zzz_mousefilter V1.0, adds some useful functions 6 years, 5 months ago #482

  • Lynxx
  • OFFLINE
  • Moderator
  • Java/C#-Developer
  • Posts: 223
Finally fixed the strange bugs it produced.

Get V1.0 now: zzz_mousefilter.script

Notes: Physions Event-System is still buggy, there even occur Events with (typeof event.type() == "undefined") .. YIEKS !
Instead of attaching a filter to the Application i changed it to mainWindow & better error-checking.
Infinity is vast, especially near end.
bye, Lynxx
Last Edit: 6 years, 5 months ago by Lynxx.

Re: zzz_mousefilter V1.0, adds some useful functions 6 years, 5 months ago #504

Hi Lynxx.
Am just responding to the word 'undefined' in this thread....
I'm only just learning this script language, and you are a proffessional, but I did
notice something the other day, when looking up some problems re: Javascript.
This may not even be related to your problem, but just in case....

It seems that 'undefined' can mean 2 things.
1 That something has actually not been defined yet.
2 That the object/variable etc., although defined presently contains 'Null'

They suggested this as the way to really check, though the syntax of your
coding will vary from this embedded html script... (notice the '===')...

<SCRIPT LANGUAGE="JavaScript1.3"><!--
var undefined;

if (typeof variable1Name == 'undefined') {
if (variable1Name === undefined)
alert('1 Null');
else
alert('1 Undefined');
}
else
alert('1 okay');
//--></SCRIPT>

Probably unrelated to your issue though, I have noticed the following.....
(Note: I'm into 2D & 3D graphics & VB prog., but trying to learn)

If, at the Physion Command line, I type....
Box1.setLinearVelocityX(2); it works, but says 'undefined' in the output window.
By typing....
Box1.LinearVelocityX = 2; (no 'set',now not a function), works, & NO 'undefined'
I asume the function expects a return value, which was not defined.

Interestingly, leaving out the 'X'....
Box1.setLinearVelocity(2,3); (or variables instead of '2' & '3')
allows me to set both X & Y properties at once, (from variables), in a loop.
Although running the code within a Physion event, (like 'OnUpdate') does not
seem to cause a problem, I worry about these 'undefined' particulars.

Sorry if this is out of context now with regard to your sub-post.
(I use your scripts all the time now! Great work. And Nait's).
1x1 square diag = root-2. Cube diag = root-3. Beautiful !

Re: zzz_mousefilter V1.0, adds some useful functions 6 years, 5 months ago #506

  • Lynxx
  • OFFLINE
  • Moderator
  • Java/C#-Developer
  • Posts: 223
Glenn555 wrote:
I worry about these 'undefined' particulars.

No need to worry, the console just outputs the result of the last action, if there was no returned value it just outputs undefined.

== compares for equal (("a"+"b")=="ab") and === for exactly the same, which should only be used with objects (like a = new Array("a"); b = a; a===b).

But undefined is not null, if you use null you have to check for it first (if (obj == null) {...), because "typeof null" will return object. (or typeof null == "object" is true).

o = new Object();
app.debug("o.test1: "+(typeof o.test)); // undefined
o.test = null;
app.debug("o.test2: "+(o.test == null)); // true
app.debug("o.test3: "+(typeof o.test)); // object

So o.test was defined, but contains no value.
Infinity is vast, especially near end.
bye, Lynxx
Moderators: Lynxx, Glenn555
Time to create page: 0.16 seconds