Jump to content

rightclick event for pixi v6


FredLin
 Share

Recommended Posts

Recently I have upgraded the pixi version of my project to 6.0.2. The first thing I noticed is that I can no longer get the event name hint by typing XXX.addListener() on DisplayObject. With pixi v5, I can get the hint of what kind of event I got there.

Second, what is the proper way to listen for the 'rightclick' event on DisplayObject in pixi v6? I can't find enough resources about this on Internet. Any help is highly appreciated!

Link to comment
Share on other sites

hu, I think is because they forget add the types events.
What you can do for temp fix , is just replace tempory :
 

declare class EventEmitter<EventTypes extends  string | symbol = string | symbol> {
// by
declare class EventEmitter<EventTypes extends  string | symbol = keyof HTMLMediaElementEventMap | symbol> {

image.thumb.png.914c0c5ba5f02992b4b1741f09b1edc8.png

or 
 

  on(event: keyof HTMLMediaElementEventMap|{}&EventTypes, fn: EventEmitter.ListenerFn, context?: any): this;
 

You shoudl find the type file in `node_modules\eventemitter3\index.d.ts`

 

------------------------------------------------------------------------

 

Quote

Second, what is the proper way to listen for the 'rightclick' event on DisplayObject in pixi v6? I can't find enough resources about this on Internet. Any help is highly appreciated!

 

 

sprite.on('pointerup', ({ button }) => {
	if (button === 0) return eventforButtonLeft();
	if (button === 1) return eventforButtonRight();
});

 

or if you need share events for preventdefault or others behavior.
 

sprite.on('pointerup', ( e, { button }=e ) => {
	if (button === 0) return eventforButtonLeft(e);
	if (button === 1) return eventforButtonRight(e);
});

 

Edited by jonforum
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...