I am trying to override backbutton in a phonegap application. but it is not working when input text box is in focus . it is exiting the app instead of the overridden behaviour . i am using
document.addEventListener("backbutton",backbuttonTap,false);
way to handle backbutton where backbuttonTap is the function . and while i am in the same page which contains input textbox, the overridden behaviour is working
Can you include backbuttonTap function's code? because I had no idea what you trying to do. but as a general answer I woill put a backbutton functionality I implemented.
function onBackKeyDown(e) {
if ($.mobile.activePage[0].id == "home"
|| $.mobile.activePage[0].id == "login") {
e.preventDefault();
navigator.app.exitApp();
}else if($.mobile.activePage[0].id == "inspection"){
e.preventDefault();
back();
//return false;
}else if($.mobile.activePage[0].id == "noDetails"){
e.preventDefault();
$.mobile.changePage("home.html");
return false;
}else{
navigator.app.backHistory();
}
}
Related
Electron application get's scaled when Ctrl Shift + or Ctrl Shift - buttons are pressed. Is it possible to get rid of those shortcuts?
UPDATE: I found this code snippet here which worked for me
window.onkeydown = function(evt) {
// disable zooming
if ((evt.code == "Minus" || evt.code == "Equal") && (evt.ctrlKey || evt.metaKey)) {evt.preventDefault()}
}
You can change the default behavior of input events on the window. When creating the window, you can add this:
window.webContents.on("before-input-event", (event, input) => {
// example this is for reloading the page
if (input.control && input.code === 'KeyR') {
event.preventDefault();
return
}
// prevent zoom in/out
if(input.control && ['Equal', 'Minus'].includes(input.code)) {
event.preventDefault()
return
}
})
I'm not including the input.shift in the check since the zoom in/out can also be done with just ctrl +/-, so this check handles both cases.
the event.preventDefault() is blocking the default behavior. You can also add other checks to prevent their default behavior (as per the example for blocking the reload event)
I have a Viewcontroller ThirdViewControllerPassenger which has multiple subviews on it, including a UICollectionView called collectionViewwith horizontally scrolling Cards. So far, so good. I have written code to be executed from a tap action from inside the uicollectionviewcells. Tapping the action does work and prints to console. However, by pressing one of these cards I want to hide the whole UICollectionView. I have set up an onTap Function as shown here:
#objc func onTap(_ gesture: UIGestureRecognizer) {
if (gesture.state == .ended) {
/* action */
if favCoordinate.latitude == 1.0 && favCoordinate.longitude == 1.0 {
//There has been an error OR the User has pressed the new Address button
//do
}else{
ThirdViewControllerPassenger().collectionView.isHidden = true
if ThirdViewControllerPassenger().collectionView.isHidden == true {
print("done!")
}
}
}
}
As you can see, I have already been troubleshooting a bit. I have tested ThirdViewControllerPassenger().collectionView.isHidden = true from ThirdViewControllerPassenger directly, which worked. It does not work, however, from a cell. The "done!" print never gets printed to console, so the call never arrives. I wonder why or what I am doing wrong.
Don't mind the first if statement, that function is not written yet. That should not matter. I am guessing that the rest of my code would not lead to any more clues.
Every ThirdViewControllerPassenger() here
ThirdViewControllerPassenger().collectionView.isHidden = true
if ThirdViewControllerPassenger().collectionView.isHidden == true {
print("done!")
}
is a new instance not the real one , you need to get access to the real shown istance
delegate.collectionView.isHidden = true
if delegate.collectionView.isHidden == true {
print("done!")
}
I already have a Model view in react native that can be accessed from a button in the settings, and I would like it to pop up the first time the app is used. In other words, I don't have any problems with the view itself, just the functionality.
I've considered user React-native-simple-store but it seems like there should be an easier way.
Thanks,
Eric
To pop-up the modal you will have to set its visible props:
<Modal visible={this.state.showModal} ...
If you save this value into AsyncStorage, or any database, like RealmDB or Sqlite, you can always read the value and then make modal show-up only once. Put it in componentDidMount :
const value = AsyncStorage.getItem('once');
if (value !== null) {
value.then((ret) => {
if (ret === null) {
// this is the first time
// show the modal
// save the value
AsyncStorage.setItem('once', 'yes');
this.setState({
showModal: true,
});
} else {
// this is the second time
// skip the modal
}
}).catch(err => alert(err.toString()));
}
In your modal:
<Modal visible={this.state.showModal} ...
In your constructor:
this.state = {showModal: false}
I have one ImageButton in my android app, and I'd like the app to change the image while the button is pressed, and when the user release the button it returns to the default image.
P.S. I'm using mono for android and I have to do this programatically, I can't use the XML tag unfortunatelly.
You can hook into the views's Touch event to do that:
var button = FindViewById<ImageButton>(Resource.Id.MyImageButton);
button.Touch += (object sender, View.TouchEventArgs e) => {
if (e.Event.Action == MotionEventActions.Down) {
button.SetImageResource(Resource.Drawable.Icon);
} else if (e.Event.Action == MotionEventActions.Up) {
button.SetImageResource(Android.Resource.Drawable.IcMenuGallery);
}
};
I want to add a button to a markitup set by which i can toggle preview, that is if i click on preview button i can see the preview, if i want to hide the preview - i can hide it by using that button. I've googleed for this but still no result. Any idea how to do that?
Nevermind, i've figured it out. I've added a button to hide it, code as below -
{name:'Hide Preview', call: function (markitUp){ miu.hidepreview()}, className:'hidepreview'}
Where hidepreview() as my custom function. I defined this function as below
miu = {
hidepreview : function(){
$('.markItUpPreviewFrame').remove();
}
}
It works for me.
You can do it by holding the Alt key and clicking on the Preview button - this will close the opened preview window.
It's in the else if statement of the preview() function:
} else if (altKey === true) {
if (iFrame) {
iFrame.remove();
} else {
previewWindow.close();
}
previewWindow = iFrame = false;
}