How to make another ImageButton appear when hovering over ImageButton - libgdx

How can i make so that if i hover over a imagebutton another imagebutton appears over that imagebutton and when you move your mouse outside it returns back to the first imagebutton? I have tried a lot of combinations but nothing so far.
So far i have tried
ImageButton(Drawable imageUp,
Drawable imageDown,
Drawable imageChecked)
but the setChecked(boolean isChecked) hasn't worked for this method and when using focusListener it turns the ImageButton into another ImageButton when you hover over it but it doesn't return to its first stage when you go outside the ImageButton. Any help appriciated.

Instead of using imageDown use imageOver.
According to my understanding:
imageUpdefault button
imageOverwhen the mouse/focus is over the button
imageDownwhen the button is pressed (the mouse is clicked)
imageCheckedwhen the button has the status checked
imageCheckedOverwhen the button has the status checked and the mouse/focus is over the button
imageDisabledwhen the button has the status disabled
You can use the ImageButtonStyle for this. Pass it to the consructor of your button or use the appropriate setter.
ImageButtonStylestyle = new ImageButtonStyle();
style.imageUp = imageUp;
style.imageOver = imageDown;
style.imageChecked = imageChecked;
Ps.:
I assumed you do not really want to change the button, just the displayed image.

Related

Need to hover on 5th rating and click on it

String exePath = "C:\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", exePath);
WebDriver driver = new ChromeDriver();
// WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://wallethub.com/profile/test_insurance_company/");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[#id='footer_cta']/span/span")).click();
// To move to 4th star over the review
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.xpath(".//*[#id='wh-body-inner']/div[2]/div[3]/div[1]/div"))).perform();
// action.moveToElement(driver.findElement(By.xpath(".//*[#id='wh-body-inner']/div[2]/div[3]/div[1]/div/a[4]")));
action.moveToElement(driver.findElement(By.xpath(".//*[#id='wh-body-inner']/div[2]/div[3]/div[1]/div/a[5]"))).perform();
action.click();[![enter image description here][1]][1]
tried the code but its not hovering neither it is clicking to go to next page
To do this, you will need to hover over the ratings section which then exposes a hidden portion of HTML that actually contains the ratings stars, etc. To find the initial element sometimes is hard because when you hover to right-click and Inspect, the element changes. What I usually do is find something nearby to Inspect and then hover the various elements until the right element is highlighted on the page. Another way to find it if it contains text is to search in the HTML for the contained text. Once you find the right element, you just need to hover it and then click on the correct star.
Since I'm assuming you will be using this code repeatedly, I write things like this into a function so that it's easy to reuse.
public void setRating(String stars)
{
// hover over ratings panel to expose ratings stars
new Actions(driver).moveToElement(driver.findElement(By.cssSelector("div.wh-rating-notes"))).perform();
// click specified star
driver.findElement(By.xpath("//div[#class='wh-rating-choices-holder']/a[.='" + stars + "']")).click();
}
and then you would call it like
setRating("5");
I have tested this code and it works.

How do a dragDrop() with the right mouse button?

Does anyone know how to do a dragDrop() with the right mouse button?
I got this example code:
image = ("image.png")
App.focus('<nameProgramHere>')
imageE = find(image)
rightClick(dragDrop(imageE, imageE.offset(Location(0, -250))))
It does make a rightclick, but the dragDrop() is preformed with the left mouse click.
(I can see this becasue the colour is then different in my program.)
I do see the rightClick() in my log.
[log] RIGHT CLICK on L(1039,556)#S(0)[0,0 1920x1080]
Found the answer myself on how to drag and drop with the right mouse button.
image = ("image.png")
imageE = find(image)
imageE.hover()
wait(2)
mouseDown(Button.RIGHT)
mouseMove(imageE.offset(Location(0,-250)))
wait(2)
mouseUp()

RollOver and RollOut effect in buttons

I'm using the code bellow to change the color of button on rollover and rollout and clicked. I have following issues in this
1. The color did not changed when button is clicked.
2. Button wont work after once clicked.
pages.gotoAndStop("home");
// list of button instance names
var previousClicked:DisplayObject;
var buttonsss:Array = [home, menudown.about, menudown.portfolio, menudown.clients, menudown.pricing, menudown.contact];
for each ( var mc:MovieClip in buttonsss)
{
mc.buttonMode = true;
mc.mouseChildren = false;
mc.addEventListener(MouseEvent.MOUSE_UP, onClick);
mc.addEventListener(MouseEvent.ROLL_OVER, rolloverEffect);
mc.addEventListener(MouseEvent.ROLL_OUT, rolloutEffect);
}
function onClick(e:MouseEvent):void
{
pages.gotoAndStop(e.target.name);
e.currentTarget.mouseEnabled = false;
TweenLite.to(e.currentTarget,2,{tint:0x666666, ease:Strong.easeOut});
TweenLite.to(previousClicked,2,{tint:null , ease:Strong.easeOut});// set the previous clicked to null tint
previousClicked.addEventListener(MouseEvent.ROLL_OUT, rolloutEffect);// restore the Roll_Over effect
previousClicked = DisplayObject(e.target); // update the last clicked button
e.target.removeEventListener(MouseEvent.ROLL_OUT, rolloutEffect);
}
function rolloverEffect(e:MouseEvent):void{
TweenLite.to(e.currentTarget,2,{tint:0x666666, ease:Strong.easeOut});
}
function rolloutEffect(e:MouseEvent):void{
//should change tint to null just when its enabled, but its changing always (enabled or disabled)
TweenLite.to(e.currentTarget,2,{tint:null , ease:Strong.easeOut});
}
How I have always done this is with the built in buttons instead of doing it with code.
If you click window up in the top bar then click on components (near the bottom) it will bring up a little window then if you expand the user interface folder and drag and drop from the button item. Then with that button on the stage if you double click on it you will go into the edit symbol screen and it will have pictures of each state that the button and if you double click on the state you want then you can visually edit that version of the button.
Hope this helped.
Note: I first started with flash pro-cs5.5 and your tag says flash-cs5 I don't know for sure if that function is available or not in 5.
I am unfamiliar with Tweenlite, but I'm guessig that what it does in this case is simply change the color, am I right? If so, I'd suggest creating the color changes on your timeline and using framelabels combined with gotoAndStop to create the different effects. This should also solve your problem concerning the button not working after it has been clicked once.

add even-listener to a button on timeline that is a grand child of a movie clip

I got a simple flash scene that contain movie clip that contain sliding button that changing every few seconds:
every layer contain a button and another movie clip.
If I want to add event-listener to a simple button on stage, i just write:
f4.addEventListener(MouseEvent.CLICK, f4Click);
function f4Click(event:MouseEvent):void
{
flash.external.ExternalInterface.call("dlHTCMD", "switchtogame?code=fnf50");
}
but when I'm trying to access the button inside the two movie clips, like
optContainer.optBeach.btnBeach.addEventListener(MouseEvent.CLICK, btnBeachClick);
and I'm adding a trace function to see if the event are triggered but nothing is happening.
looks like a simple problem but i didn't find a solution.
I thought about extending the button class and add a bind function with the value as the name of the button and set the Event Listener but I'm not an AS3 expert :(
Thanks.
Try this:
// Pass mouse events to children
optContainer.mouseChildren = true;
optContainer.optBeach.mouseChildren = true;
// Reset hit area
optContainer.hitArea = null;
optContainer.optBeach.hitArea = null;
// Reset masks
optContainer.mask= null;
optContainer.optBeach.mask= null;
Also check whether on each key frame button have name.

AS3 - Unable to capture button click when using Mouse Move listener

In my first AS3 project (not used Flash since AS1) I need to use a custom movie clip as a cursor and detect clicking on a button. Using the code below, the custom cursor works as expected, but I am unable to capture clicking on the button.
If I comment out the first line, the trace for clicking works as expected. I have tried changing the order of the event listeners, applying the follow to the button rather than the stage, but cannot get both to work together.
Any advice as to where I'm going wrong ould be appreciated.
stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
start_button.addEventListener(MouseEvent.MOUSE_UP, playPhrase);
function playPhrase(event:MouseEvent) {
trace("Click received");
};
function follow(event:MouseEvent) {
cursor.x = mouseX;
cursor.y = mouseY;
};
Looks like that's because you always click on the cursor object as it always positioned right under mouse cursor. Make it "transparent" for mouse clicks:
cursor.mouseEnabled = false;
And if it's a DisplayObjectContainer then also:
cursor.mouseChildren = false;