How can I move element from one window to another [geb] - groovy

I am testing web-aplication and I need to move element from one window to another.
Geb has clickAndHold() function but that doesn't work for me because offset works only with one window. any suggestions?
interact {
clickAndHold($('#draggable'))
moveByOffset(150, 200)
release()
}
edit: it is not possible to do it with web driver. you are restricted to only one window and can't go outside of it (draging an object from one window to another), but we managed to do it with java.awt.Robot

Related

posenet p5js position stops updating when I move to another tab

I'm coding with posenet and p5js. I made a grid on my screen which plays different audio fragments on different x ranges. This works very well. However, if I keep it running and open another tab in my chrome webbrowser, the x position gets stuck in one area (it doesn't update anymore) and the same audio fragment is repeated until you get crazy.
Is there a way I can prevent this?
Well, some code would be great to be honest, but variables shouldn't really get stuck if you open another tab and so on, are you sure you haven't just missssspelled some variable, or some function or did one of those random mistakes?
If it truly is the p5.js I guess just try checking everytime draw fires if your canvas is still focused.
I believe you can also have canvas.hasFocus... exept you'd have to declare createCanvas as a variable (cause canvas is basically just a button or a textArea to html and javascript and p5)
Also I think there's a command to only allow for one audio channel and stuff in js and p5...
function draw() {
if(document.hasFocus()){
// all of your other code even
// background() and stuff...
}
}

Move view from top to bottom continuously without animation in Android

I want to know how to move a view from top to bottom continuously without animation. I am asking this because I want to get the position of the view at every step so that I can check that if there is any collision between that view and any other view.
With animation you can move (not exactly move) a view from one position to another position (Animator class), but animation produces an illusion to the user that it is moving but it's position is fixed all the time. So this can't be done using animation?
Second approach is incrementing position of view. I applied this method in onCreate(). If I used it without Thread.sleep(50) then the activity doesn't show the view, if I applied it with Thread.sleep(50) then activity doesn't start for some period.
Property animation (subclasses of Animator class) actually move the view, as they update the actual property of the view. It is the view animations (subclasses of Animation class) that don't move the actual view and instead just where it appears to the user.
Source:http://developer.android.com/guide/topics/graphics/prop-animation.html
Quote: With the property animation system, these constraints are completely removed, and you can animate any property of any object (Views and non-Views) and the object itself is actually modified.
You also shouldn't start moving things around in the onCreate method as things are still initializing (onwindowfocuschanged is recommened). Also if you call thread.sleep, you are going the sleep the main UI thread, hence freezing the application for a time.
Solved the problem using ValueAnimator :-
CodeSnippet :-
va=ValueAnimator.ofFloat(0.0f,size.y);
va.setDuration(5000);
va.setRepeatCount(va.INFINITE);
va.setRepeatMode(va.REVERSE);
va.start();
va.addUpdateListener(new AnimatorUpdateListener() {
#Override
public void onAnimationUpdate(ValueAnimator animation) {
// TODO Auto-generated method stub
bullet[0].setTranslationY((Float) va.getAnimatedValue());
Rect R11=new Rect(bullet[0].getLeft(),bullet[0].getTop()+(int)bullet[0].getTranslationY(),bullet[0].getRight(),bullet[0].getBottom()+(int)bullet[0].getTranslationY());
Rect R21=new Rect(ball.getLeft(), ball.getTop(), ball.getRight(), ball.getBottom());
if(R11.intersect(R21))
va.cancel();
}
});

How do you make your MDI MFC app show one instance in the TaskBar?

I have an MDI app and when I click new document, it opens up a separate tab. This creates another instance of the icon in the taskbar within Windows. Is there any way I can change this behavior so that only one icon instance is shown the taskbar?
I know one way is to use SDI and use tabs for my views, but I want to keep it an MDI. Is this even possible.
I'm trying to mimic the view of this particular application called 'Dameware NT Utilities':
http://www.dameware.com/v3-dameware/media/DameWare/DW%20NTU/Carousel/DRS-Primary-medium.png?width=490&height=276&ext=.png
I found the solution after a day of digging around. Gosh, that feels good to finally figure this out. Anyway here is the solution.
I just had to override the childframe's CanShowOnTaskBarTabs() method to return FALSE. Here's the class method:
first, in the childframe.h file, put the following code in the class declaration
public:
virtual BOOL CanShowOnTaskBarTabs() override;
Then in your childframe.cpp file, put the following code at the very bottom:
BOOL CChildFrame::CanShowOnTaskBarTabs()
{
return FALSE;
}
Here's more information on the subject: http://msdn.microsoft.com/en-us/library/ee256255(v=vs.100).aspx
I have an easier solution. On the app class InitInstance() method, just call
EnableTaskbarInteraction(FALSE);
before the main frame has been created. Then you will get one view per application instance when mouse does fly hover on its Taskbar icon, instead of one per sub-winodow.

How to save the window state at wxWidgets?

I'm constructing a UI using wxWidgets.
In my GUI, I generate a window (wxFrame class) which is accessible through pushing a bitmap button. In that window, I also perform some tasks, again pushing some bitmap buttons and diabling them etc. But I can't close and reopen that window with the state saved. I always have to re-initialize it, and this is very impractical.
How can I save the state of my window? I checked the internet, it's suggested to use wxPersistent class but this class is missing in my wxWidgets.
Thank you for any help,
Best Regards.
Instead of destroying the window every time, you can just hide it with the wxWindow::Show() member function, passing false as the argument, when you receive a wxCloseEvent. You then veto the wxCloseEvent to prevent WxWidgets from destroying your window:
// In your close handler:
if(evt.CanVeto()) // Where evt is a wxCloseEvent
{
Show(false); // Hide window
evt.Veto(); // Prevent window destruction
}
This should remove it from the screen, but all the initialized parts should still be there. If you need to show it again, call the Show() method again with true.

How to change the function called when I click in the close button on php-gtk?

I load a single instance of a window on php-gtk, I have a button named "Cancel" that hide(); the window, so when the window is needed again I just show();.
But when I click on the close button instead of the cancel button the window is destroyed. Even when I redirect the event (I'm not sure if i'm doing it right) it calls the first(just hide() function) and then the destroy method.
Any idea?
PD: I wouldn't want to destroy and recreate the windows because of php's crappy garbage collector and to be able to maintain previous data without having to refill the whole window(after all is supposed to be a desktop app).
Following the advice here: delete-event.
I changed my code to return TRUE:
function on_multipleCancelButton_activate()
{
global $GladeMultiple;
$MultipleWindow = $GladeMultiple->get_widget('multipleWindow');
$MultipleWindow->hide();
return TRUE;
}
On the GTK designer I linked the delete-event to this function.

Resources