Jump to content

Difference between ActionManager and Observable


yuccai
 Share

Recommended Posts

Hello,

I find that the Observable class is useful to handle events. However the ActionManager class offers more types of events such as long press for instance but we can only use it on meshes.

I would like to know the fundamental difference between these two classes. Does one depend on the other ? How can I reproduce the events from ActionManager for the Observable ?

 

Thanks

Link to comment
Share on other sites

In fact that's a good question. ActionManager is used to manipulate events on meshes, but if you want to catch those advanced events outside a mesh (on scene for instance), I think you have to implement yourself the same mechanims already set in scene.attachControl (which raises the ActionManager events).

We should create new "advanced" Observers (longpress, leftpick, etc) in BJS and automatically notify them same time as ActionManager. I'll have a look at this.

BTW, I've just noticed that ActionManager's doc is not up to date (eg, it is not explained that the difference between onPickEvent and onPickDownEvent is that onPickEvent is only triggered if mesh is clicked but not dragged, while onPickDownEvent is always trigged when mesh is clicked), I'll fix this.

 

Link to comment
Share on other sites

  • 2 weeks later...

@Deltakosh I have some questions relative to the implementation of the new custom Observers.

¤ My concern is about the fracking names of the new events, mostly because click is for a mouse and tap is for touch... and I don't know what to choose to express both. I remember having the same question when working on ActionManager, but that was solved by distinguishing pick and down. But for Observers I can't use pick, since pick tells us that a mesh is picked, but in Observers there is nothing to pick, we are at scene level...
POINTERDOWN already exists and is ok. The new event should be a POINTERCLICK / POINTERTAP, whatever the name it must explicitly tell that we are talking about a single click (with no following drag). Do you have a name suggestion? CLICK, POINTERCLICK, POINTERTAP, POINTERSCHTROUMPF, POINTERPICKINGOFNOOBJECTBUTITSASIF, going crazy, I need a hand...knowing that I also will have a double click event...)

¤ For the double-click event, should the simple click also be raised when double-click happens?
I had a look at usual usage, and it tends to be that way (double raises a single first), It is, then, up to the user to handle that the way he wants (for instance waiting for double-click delay before doing something with simple click).
But I think it would be more interesting for BJS to provide users a nicer event manager, where they can choose if they want, or not, to raise a previous simple click on double-click listening.
For this we can implement a kind of "exclusive" double-click. When activated we do not raise single click on double-click event (and the user do not have to manage that himself), but that also means in this mode every single click is trigged with a delay (waiting to be sure this is really a single and not a double). Do you think this could be interesting?

If yes, we have two possibilities:
1. we implement an other event mask (EXCLUSIVEDOUBLECLICK?, EXCLUSIVEDOUBLESCHTROUMPF?)
2. we add a flag somewhere (exclusiveDoubleClickMode, false by default, but where to add it?, in Observers, in Scene...)
Which one do you prefer?

Link to comment
Share on other sites

First of all, how do you plan to implement POINTERTAP (like this one ;)) ? I need to be sure this will not slowdown rendering

Same for POINTERDOUBLETAP (do you like it?). I do not want to over engineer the event part. I don't think there is a big ask for a way to configure single/double listening.

Link to comment
Share on other sites

POINTERTAP will be implemented the same way as ActionManager OnPickTrigger.

POINTERDOUBLETAP will be implemented by checking time between previous click and current click, if lower than particular delay, it is a double click. At first click, a click is raised, at second click, the time is checked, and a click or a double-click is then raised. If exclusive double click mode is set (not set by default), every click will wait for this specific delay before raising (to determine if single or double).

Link to comment
Share on other sites

Huh, for whatever reason i thought "standard" double click === 2 x "full clicks" but now that i tried it to open a text file, the double click indeed triggers on click down. I suppose i just usually release the click so fast i haven't noticed you don't actually have to let it go for the double click to active. Interesting. :lol:

Well, anyway... what i wanted to throw out there is: since this double-click business seems mainly time related (what else is really different between single and double click?), could there perhaps be a place for some kind of action that helps with time instead of just clicking. I'm thinking something that lets you disable / modify / override already existing actions, or add completely new actions / inputs, but only for a period of time. So you could just have your normal click trigger/action, but then you could have some other action to say that for the next 500ms when you click; do something else than the normal click instead. And if this was possible then you could use that for all kinds of different things, like click some thing and then for the next 3 seconds if you press some key on keyboard do something. And then after the time is done, that input / action is removed.

Link to comment
Share on other sites

OK, PR is on its way (under yuccai's git account).

Sorry for not being "step by step", there are in fact three new events in this PR :

  • POINTERTAP (the equivalent of ActionManager.onPointerPick, but at scene level)
  • POINTERDOUBLETAP (to catch double click, at scene level)
  • onDoublePickTrigger (ActionManager event to catch a double click on a mesh)

Of course implementation is open for discussion in the github pull request.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...