Go to the specific tab when backed from a screen - codenameone

How can I go to a specific tab when backed from a screen? Lets say I am in newForm screen and when I touch the back button, I'll go to Home screen. There are 4 tabs in homeScreen and I want to go to 3rd tab as soon as I've backed to home.
Home class
Tabs tabs = new Tabs(Component.BOTTOM);
tabs.addTab("Home", icon, homeContainer);
tabs.addTab("Home1", icon1, home1Container);
tabs.addTab("Home2", icon2, home2Container);
tabs.addTab("Home3", icon3, home3Container);
add(BorderLayout.CENTER, tabs);
Button newForm = new Button("New Form");
newForm.addActionListener(e=>{
new NewForm(res).show();
});
NewForm class:
Command back = new Command("") {
#Override
public void actionPerformed(ActionEvent ev) {
new Home(res).show();
}
};
.setBackCommand(back);

I would suggest keeping an instance of the Home form and just using Home.getInstance().showBack(). This will mean that the last selected tab would remain "as is".
If you want to select a specific index use: tabs.setSelectedIndex(idx, false).
Notice that the index starts at 0.

Related

How to get Parent id on Related list in salesforce

How to get parent id on custom button click of the related list.
Question Exploration:- when we open the Account detail record page and go in the related tab we have a contact list there and a new button on the contact list tile...when we click that new button new record modal is open with a pre-populated account in it.
so, I have to create a custom button that does this same thing.
When you click your custom button, the context is passed in the URL as a variable named inContextOfRef and the value is a base64-encoded string. You can get this value from the URL and decode it in your component. For LWC, you could do something like this:
import { LightningElement } from 'lwc';
export default class MyCoolLWC extends LightningElement {
// this variable will contain the parent record Id
recordId;
// this executes when your LWC is loaded
connectedCallback() {
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop)
});
let inContextOfRef = params.inContextOfRef;
if (inContextOfRef.startsWith("1\.")) { inContextOfRef = inContextOfRef.substring(2); }
var addressableContext = JSON.parse(window.atob(inContextOfRef));
this.recordId = addressableContext.attributes.recordId;
}
}

ReactJS Show alert when user leaves the current browser tab

I would like to lock users on the page. The users can go on other tabs or desktop at least when they click on other tab of browser I would like to show them alert dialog which say "Are you sure?"
Hi guys Thanks for helping
I find code which is I need :
requestFullscreen = () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else if (document.exitFullscreen) {
document.exitFullscreen();
}
};
then I called this function onClick event on Button. After that I will check when User try to left page (alt+f4, alt+tab .. etc) I will show alert for "Are you sure for left page "

Why am I seeing this weird lag when going between pages?

When clicking on an icon in the AppBar that's supposed to take me to my Profile page there is some weirdness. The contents of the Profile page immediately show up on top of the previous page and then a second later the Profile page loads and everything is fine. Same thing happens when going back from Profile page to the previous page.
Here is a link to the screen recording https://vimeo.com/user99110764/review/339241883/a39312e6d8
Below is the code for the Profile button that is in the AppBar
class ProfileButton extends StatelessWidget {
final store = AppStore.store;
#override
Widget build(BuildContext context) {
return IconButton(
onPressed: () async {
if (store.state.userState.user == null) {
AppNavigator.signInPage();
} else {
AppNavigator.profilePage();
}
},
tooltip: 'Profile',
icon: Icon(Icons.person),
);
}
}
EDIT:
static profilePage() {
navigator.currentState.pushNamed('/profile');
}
static signInPage() {
navigator.currentState.pushNamed('/sign_in');
}
Since the video is not working I'll try to explain what's happening. I'm on the main page of the app that has a list view. I click on the profile button in the AppBar after I've already signed in so it navigates to the Profile page, but what happens is that the contents of the Profile page (image + logout button) get immediately rendered on top of the main page and after about a second, the background of the Profile page loads and everything looks how it's supposed to.
An async function uses the await expression. Hopefully, this could help...Dart asynchronous programming

How can i call to specific index of tabs in ionic 3.20 from child page?

Suppose,
i have tabs page which contained 3 index page. Index page 1 is home page and index page 2 is products page and index 3 is cart page. When i nav push to search page from home page , there is a button. I wanted to click that button to go to directly tabs index page 3. How can it possible?
Thanks in advance.
First, you need to import Tabs from ionic-angular in your search.ts
import { NavController, Tabs } from ionic-angular;
export class SearchPage {
// then assign the navctrl parent to the tab
constructor(public navCtrl: NavController, public tab: Tabs) {
this.tab = this.navCtrl.parent;
}
// create a method that will be called after click
goToTab(){
this.tab.select(3); // depends on what index of the tab you want to go
}
}
In your search.html
<button (click)="goToTab()"> To other tab </button>

CEFSharp options for a new popup window

I have a WPF application using CEFSharp and it is working perfectly well except for one small thing. If I have a link with the target=new so the link should open in a new browser window it opens fine but the window has no icon on the top left just that default "I couldn't find an icon, icon"
Also is there a way to control the state of the new window i.e. maximized.
Or is there a way to catch the click and perhaps force the new browser to be the users default on their system.
Any suggestions appreciated
Or is there a way to catch the click and perhaps force the new browser to be the users default on their system. Any suggestions appreciated
Yes, you can catch it and prevent the new window.
Have a look at the IRequestHandler and ILifeSpanHandler interfaces.
internal class RequestHandler : IRequestHandler
{
public bool OnOpenUrlFromTab(...)
{
Process.Start(targetUrl);
return true; //Handled
}
...
}
internal class LifeSpanHandler : ILifeSpanHandler
{
public bool OnBeforePopup(...)
{
newBrowser = null;
if (!String.IsNullOrWhiteSpace(targetUrl))
{
Process.Start(targetUrl);
return true;
}
return false;
}
...
}

Resources