BitmapButtonField Listener - button

In application I have implemented BitmapButtonField with image. On click of BitmapButton I have to integrate Facebook application. I searched for click event of bitmapButtonField but nothing is working.
Facebook = new BitmapButtonField(
Bitmap.getBitmapResource("facebook.png"));
Facebook.setMargin(0, 10, 0, 10);
horizontal_field.add(Facebook);
Facebook.setChangeListener(this);
If I'm testing this on touch listener phone. Its is working. If we have device without touch its not working.
Thanks

You have to pass the style property ButtonField.CONSUME_CLICK. So you can make the button clickable. you can use this constructor of the BitmapButtonField Class
BitmapButtonField( Bitmap normalState, Bitmap focusState, long style )
for exaple:
Facebook = new BitmapButtonField(Bitmap.getBitmapResource("facebook.png"),Bitmap.getBitmapResource("facebookFocusState.png"), ButtonField.CONSUME_CLICK);
That worked for me. on trackPad BlackBerry Phones

Related

Telegram Web Apps method Expand isn't working

I found that the method Expand of window.Telegram.WebApp object isn't working in the Telegram client for Windows and IOS on computers and tablets.
How to increase the size of Web Apps frame for those devices?
function buttonOn(){
// do something on btn click
}
let main_page = document.querySelector('#main_page');
if (main_page){
window.Telegram.WebApp.expand() //expand window after page loading
window.Telegram.WebApp.MainButton.onClick(buttonOn) //set func on main button click
window.Telegram.WebApp.MainButton.setParams({'text': 'Корзина'}) // set byn params
window.Telegram.WebApp.MainButton.show() //show telegram btn
}
Other button events
Remove the line from the function:
window.Telegram.WebApp.expand() //expand window after page loading
And call it in the beginning/at the top of your main javascript code. (The code that will start running once the user has clicked on the button)
Also, you can make your code a lot shorter by putting window.Telegram.WebApp in a variable like:
const tele = window.Telegram.WebApp; //Initializes the TELEGRAM BOT and
//Gets the user's Telegram ID from the Telegram API
tele.expand(); //Expands the app on the users' phone to 100% height
The reason is, probably, you are a bit incorrect in understanding what "expansion" is. This term could only be applied to mobile devices with OS such as Android or iOS. Web App is displayed there in such native component as BottomSheet with inserted WebView containing your web application. Initially, in mobile devices, application is being opened minimized (not expanded). To make it use maximum allowed height of screen, you could call expand() method. It must work through window.Telegram.WebApp.expand().
In desktop or web versions of Telegram, Web App is displayed in separate component which is not allowed to change its size.
You could probably find more useful information about viewport and expansion here, or use alternative libraries, such as twa-bridge or twa-sdk

A-frame automatically entering in full screen mode oculus go

I am using A-frame for building a VR website. I wish to enter vr-mode without having to press the 'enter-vr' glasses on the oculus go more than once. For my application most of the html (including the a-scene) get reloaded (but the header/footer remain in place). For pc browsers this code works:
HTML:
<a-scene id="eqvrscene">
</a-scene>
<button id="enterVRButton" onclick="$('#eqvrscene')[0].enterVR();"> Enter VR </button>
JS:
$("#enterVRButton")[0].click();
but this does unfortunately nothing on the oculus go. Does anyone have a suggesting how to tackle this problem?
This may or may not be related, but you have a typo in your <a-scene> tag.
It's difficult to tell from your code, but are you sure your scene is loaded when you click the button?
Try first listening for the loaded event of the scene, and then setting up a listener for the button:
// Scene entity element
var scene = document.querySelector('a-scene');
// Button element
var enterVRButton = document.querySelector('#enterVRButton');
// Check if scene has loaded, otherwise set up listener for when it does.
if (scene.hasLoaded) {
addButtonListener();
} else {
scene.addEventListener('loaded', addButtonListener);
}
// Add our button click listener.
function addButtonListener() {
enterVRButton.addEventListener('click', function() {
scene.enterVR();
});
}
In A-Frame master branch, there is an API in place for adding a custom button for entering VR, so it may be released in 0.9.0. See the master docs: https://aframe.io/docs/master/components/vr-mode-ui.html#specifying-a-custom-enter-vr-button
If you're trying to automate the click event, I don't believe this will work in many browsers, as a user interaction is required for enterVR().
It’s not posible. The WebVR API does not allow to enter VR mode automatically. It requires a user gesture like a click that cannot be synthetized like your example does. The only exception is when a page enters VR mode after user gesture, new pages are granted permission to enter VR automatically after navigation. A-Frame already accounts for the scenario and no extra application code is necessary.
Firefox also grants permision to enter VR automatically on page reload. That’s why you might be seeing a different behavior on desktop. Your code is not necessary, A-Frame auto enters VR automatically already. This case is not covered in the Oculus Browser

Unable to click on a button inside an iframe

Scenario:
Launch http://www.indiabookstore.net/.
Click on FB like button which is inside an iframe. (scroll down to see it)
Issue:
I'm able to switch to the iframe, but couldn't click on the button, as there is a NoSuchElementException
I tried giving relative as well as absolute xpaths, didn't work.
Try out this way...
driver.switchTo().frame(
driver.findElements(By.tagName("iframe")).get(2));
new WebDriverWait(driver, 20).until(
ExpectedConditions.elementToBeClickable(By
.xpath("(//span[.='Like'])[1]"))).click();
I tried couple of times executing through WebDriver, but facebook like button is not coming up. So i tried for Twitter with below code, which worked for me.
WebDriver driver = new FirefoxDriver();
driver.get("http://www.indiabookstore.net/");
Thread.sleep(10000);
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[#class='home-twitter']")));
driver.findElement(By.xpath("//span[#class='label']")).click();
Watch the above said video else watch this video to know more about switch between frames: https://www.youtube.com/watch?v=yYv_7-zYz4k
The following code should work for fb Like button:
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://www.indiabookstore.net/");
driver.switchTo().frame(driver.findElement(By.xpath("//html/body/div[1]/div[11]/div[1]/div[2]/div[1]/div/span/iframe")));
WebElement fb = driver.findElement(By.xpath("//html/body/div/div/div/table/tbody/tr/td[1]/div/form/div/div[1]"));//fb Like button
Actions builder = new Actions(driver);
builder.moveToElement(fb).click().build().perform();
driver.switchTo().defaultContent();

How can access the uibutton ,when apply the UIPanGestureRecognizer to the same button

I am new in ios development.Now, i am developing a small application with GestureRecognizer.
In my application has some uibuttons and this buttons respond to UIPanGestureRecognizer.
Now i want to identify which button is dragging,when applying the UIPanGestureRecognizer.
if anybody know .please clear my question.
maybe something like this would work for you
- (void)pan:(UIPanGestureRecognizer *)gesture
{
UIButton *button = (UIButton *)gesture.view;
}

How to embed "Share on Facebook" button into Flex application?

I'm trying to duplicate the behaviour of the "Share on Facebook" button from Youtube. Basically, inside a Flex app I'll have a button and when I click it I want a popup that enables me to post something on the wall.
While it is possible to make a call to javascript to open the pop-up I want to be able to set the images and the text of my posting.
Do you know how I could set the images or text as a paramter to the sharer window?
Thank you!
This is fairly straightforward to do. Youtube uses the Facebook API which pops up a new window (Info on Facebook sharer API).
To do this in flex,
Create a button that onClick will call a javascript method, ExternalInterface.call("fbLink", "www.yahoo.com");
In your HTML file (most likely index.template.html) add the JavaScript method, fbLink which does the following:
function fbLink(url) {
window.popup("http://www.facebook.com/sharer.php?u=" + url, {height:440, width:620, scrollbars:true})
}
Now when a user clicks on the button they will be sharing the link "yahoo.com" with facebook account.
as I understood you asking for some help in accessing js popup in html page of facebook share button, so you should use ExternalInterface in this casa and access needed DOM node using getElementById function in your js interface.
In other case I want propose you to read another one way http://www.riaxe.com/blog/flex/publish-into-facebook-wall-from-flex/
It seems that you want to have a button on the flash application and once clicked it opens the facebook page that shares the video/image that pertains to the clicked button. What you want to do is simply create a button that on click opens a new website to facebook using their share api which has the following format:
var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText";
Where the u parameter stands for the link that you wish to share, and the t parameter stands for the title of the piece that you want to share, whether it be a picture or video.
You want to add an event listener on MouseEvent.CLICK that has as its callback function a method that handles the opening of the facebook page passing the facebookShare variable as shown above. To open another page on your browser you can use this AS3 Class called URLNavigator: http://www.danishmetal.dk/project/source/com/zorked/URLNavigator.as
To sum it up, something along these lines would do:
var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText";
facebookButton.addEventListener(MouseEvent.CLICK, this._goToUrl(facebookShare));
private function _goToUrl(link:String):Function {
var window:String = "_blank",
feats = "",
thisOverlay:Object = this; // to not lose scope when returning a func
return function (e:MouseEvent):void {
trace("Opening link to:"+link);
try { URLNavigator.ChangePage(link, window, feats); }
catch (e:Error) { trace("error launching "+link+" in "+window+" with feature set "+feats); }
}
}
I hope that helps. If you have questions regarding the code please let me know.

Resources