I'm using Potree (https://github.com/potree/potree) for the visualization of a massive point cloud.
I'm starting an area-measurement (Potree.MeasuringTool) which is normally stopped/accepted by a right-click. I'd like to want it to stop at the click of a button. Can someone point me in the right direction which function to call? I'm not that into javascript. Also, a simulation of a right-button click will be accepted by me, although it's maybe not the prettiest solution.
without event :
viewer.measuringTool.sceneMeasurement.remove(viewer.measuringTool.sceneMeasurement.children[viewer.measuringTool.sceneMeasurement.children.length - 1]);
Tried every possible solution/function saying something about cancellation of a measurement. Found out this was just what I needed in potree.js;
viewer.dispatchEvent({
type: "cancel_insertions"
});
Of course, this is only applicable if the measurement is still active.
Related
I wrote a PanelMenu.Button-derived class for shell 3.36 by following the tutorial at:
https://wiki.gnome.org/Projects/GnomeShell/Extensions/Writing
Everything works (after a few 3.36-related tweaks I had to do) but now I would like to have a single left click show/hide the application and single right click open the menu. For that I wanted to catch a 'clicked' signal but PanelMenu.Button only emits menu-set. I'd need something like this:
indicator.connect("clicked", () => GLib.spawn_command_line_async("my_app"));
Is there a widget that supports the 'clicked' signal?
I think looking for a another widget might be more work than it's worth. If you look here at the implementation, they're really just overriding the event vfunc to open the menu.
vfunc_event(event) {
if (this.menu &&
(event.type() == Clutter.EventType.TOUCH_BEGIN ||
event.type() == Clutter.EventType.BUTTON_PRESS))
this.menu.toggle();
return Clutter.EVENT_PROPAGATE;
}
If you've subclassed yourself and don't need the menu, you can simply do a similar thing just by redefining the virtual function like so (just put this in your subclass like a regular function):
vfunc_event() {
if ((event.type() == Clutter.EventType.TOUCH_BEGIN ||
event.type() == Clutter.EventType.BUTTON_PRESS))
GLib.spawn_command_line_async("my_app");
return Clutter.EVENT_PROPAGATE;
}
However, you may want to change the events to BUTTON_RELEASE and TOUCH_END so it happens when the user releases the button, giving them a chance to change their mind by dragging the mouse away.
Did you try:
indicator.connect("button-press-event", () => GLib.spawn_command_line_async("my_app"));
The signal you are looking for should be: button-press-event.
A single left mouse button click will trigger the button-press-event.
This signal works for me. My GNOME shell version is: 3.36.9
Regarding your second question:
is there a preferred way to show/hide a window of a running application?
This link may be able to help you or will hopefully at least give you some pointers in the right direction:
https://github.com/amivaleo/Show-Desktop-Button/blob/master/extension.js
Good Luck!
Self-Replicating Popup WORKS! However in CHROME the popups just stack on top of each other. WAS looking for assistance on how to make them appear at random positions. Have edited question now that it's solved.
To give you an idea, here is the code I WAS using to make the popup replicate itself (JS only, I don't need to show you how to implement full-page YT videos):
<script type="text/javascript">
window.onload = function(){ window.open("file:///C:/Windows/System32/popup.html", "", "width=300, height=200") }
window.onunload = function(){ window.open("file:///C:/Windows/System32/popup.html", "", "width=300, height=200") }
</script>
The idea is that the popup is just a HTML file hidden in the VM (hence why no JQuery, AJAX, etc).
Finally: I would really appreciate the help. Whoever is the first to post the best solution gets best answer, and shoutout in credits of the released app and future YT videos (demos and DIY tutorials). Also be kind, web dev isn't my strong suit!! Thanks guys.
NOTE ABOUT ANSWER: Syntax has slight mistake at the end (I didn't even notice at first took me about 10 minutes of staring at it scratching my head to notice.
window.open('about://blank', '', 'width=300, height=200, top='+(Math.random()*screen.height)+', left='+(Math.random()*screen.width)+'')
It's exactly the same as the answer supplied by Villa7_ but you missed the [ + ' ' ] in between the two parentheses at the end, and for some reason dreamweaver (I know, leave me alone) kept flagging up a syntax error whenever I added the semicolons...
Thank you though, this was EXACTLY what I was asking for :) for some reason I can't give a vote though, only select your answer. Will give you the shoutouts I promised :) Very simple, love it!
random position:
window.open('about://blank', '', 'width=300,height=200,top='+(Math.random()*screen.height)+',left='+(Math.random()*screen.width));
I have a problem with using $ionicScrollDelegate.scrollTop()
I need to scroll down my book list to appropriate book after going out from the reader. I desided to use $ionicScrollDelegate.scrollTop() for this purpose.
It works, but I cannot scroll up my list manually after that.
Maybe someone knows why it happens.
Here is my code:
$timeout(function(){
var BooksListScroll = $ionicScrollDelegate.$getByHandle('BooksListScroll');
$location.hash("main" + $rootScope.currentBookCode);
BooksListScroll.scrollTop(true);
}, 500);
If you are using android platform to do a test, remove the 'true' value on the function. Ex:
BooksListScroll.scrollTop(true);
to
BooksListScroll.scrollTop();
Do a try.. IOS is working fine with the scroll animation but on android the scroll animation make the view freeze! Weird! :(
UPDATE (SOLUTION):
Okay I found the solution.. It seem we need to set 'jsScrolling: true' instead of by default is 'jsScrolling: false' for android.
Please modified/edit this on 'ionic-angular.js'
Hope it help others :)
In the beginning of my code, I set a tick event. These 3 following lines work.
createjs.Ticker.addEventListener("tick", handleTick);
createjs.Ticker.useRAF = true;
createjs.Ticker.setFPS(30);
I would like to remove the listener at the end of my code. I tried to call it like that but it doesn't work:
createjs.Ticker.removeAllListeners();
The Firefox console says me createjs.Ticker.removeAllListeners is not a function.
So i tried to switch to the other one:
createjs.Ticker.removeEventListener("tick", handleTick);
And It also doesn't work.
I don't really know how to use it. On the official website they use it with a displayObject, but I don't create it link to a button or something else.
http://www.createjs.com/Docs/EaselJS/classes/Ticker.html#method_removeAllEventListeners
Could someone could help me to solve it please ?
Thanks
EDIT: I'm using the easelJS version 0.7.1 but I think my problem is linked to a tutorial using an older version of easelJS (0.5). Does anyone know how to adapt it the the latest version of easelJS ? thanks
EDIT 2: I found on this link (http://www.createjs.com/Docs/EaselJS/modules/EaselJS.html) the utilization of createjs.Ticker.addEventListener("tick", handleTick); in the latest version of easelJS, but there is no documentation about how to remove the listener called from createjs.Ticker, i'm still looking for a solution
I think the function you are looking for is:
createjs.Ticker.removeAllEventListeners(); // Note the function name
The second example should work, assuming you are not proxying the function to maintain scope. Ticker is an EventDispatcher, and inherits all the methods defined here: http://www.createjs.com/Docs/EaselJS/classes/EventDispatcher.html
The evt.remove() is a great shortcut, if you don't have a reference to the function.
One important note: If you remove ALL event listeners from Ticker, you may inadvertedly stop Tween from working. Tween adds a listener when it is initialized. Your best option is the second option where you remove the listener entirely. If you still can't get it working, feel free to post some more code, and I will try and help out.
Cheers.
I use the // alternately: evt.remove(); call.
Using a global var, when I set this one to true, I call the evt.remove() function. But It might not be the best way to do it.
I'm trying to understand the flowplayer API, I'll be honest, I really need examples to get this stuff. I know some of you ninjas know what you're doing quite easily.
I am building a video training page for someone. It uses a PHP (kirbycms) framework to generate pages. I understand how to drop my variables and all that stuff. I have the videos working. It would be largely beneficial if I could have cue points that trigger things, and buttons that seek to specific time codes. It would be best if I can use PHP to define a string for these links.
I am looking for an example on how to use seek(time, [callback])
I am also looking for an example of
$(".player").bind("cuepoint", function(e, api, cuepoint) {
// here we use custom properties left, top and html
$("#info").html(cuepoint.html).animate({
left: cuepoint.left,
top: cuepoint.top
});
});
Update
Included bootply, this still does not work for me. Is it because my controls are outside of the flowplayer window?
http://bootply.com/86532
seek function (as documentation says: CLICK) is for jumping into given time on the timeline:
seek(time, [callback])
It takes two arguments: time in seconds and a callback - function that will be executed after jumping into that time on the timeline. Assuming that you are using jQuery you can write something like this to jump into 15.5s of the movie if you click button and then alert some message (just a simple example):
flowplayer(function (api, root) {
$("#someButton").on('click' function(e){
e.preventDefault();
api.seek(15.5, function(){
alert("you've jumped to 15.5s of the movie!");
});
});
});
Flowplayer doesn't do what you're after. In fact, seek() pretty much does the opposite- it triggers the video to jump to that point in time (and optionally calls back when its done).
If you want to set cuepoints and have the video trigger code when the video reaches those points in time, have a look at addEventListener("timeupdate", callback), see docs.
You might also want to check out popcornjs.