CEFSharp options for a new popup window - wpf

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;
}
...
}

Related

How to show popup on page leave with React router?

So I want to show user a popup when they try to leave the page. The popup will have to buttons - on to save content and leave and another to just leave without saving.
I'm using router 3.2.1
I tried to make use of routeLeaveHook functionallity, and it works to open the dialog.
But the problem I'm facing right now is I'm not sure how to handle two functions which should run on button clicks? Should I push to history in them to navigate to the clicked page? How can I get nextLocation there? Or should I use routeLeaveHook somehow? Or is there another way to do all of it?
Thank you for your help!
class MyDialog extends React.Component {
componentDidMount(): void {
const { route, routeLeaveHook} = this.props;
routeLeaveHook(route, this.routerWillLeave);
}
routerWillLeave = (nextLocation: string): any => {
if (dataToSave) {
...open dialog
}
return false;
}
render () {
<div open={isOpen}>
...some content
<button onClick={this.saveAndLeave}>
Save and leave
</button>
<button onClick={this.leave}>
Leave
</button>
</div>
}
}
UPDATE
Right now I think I should move my routerWillLeave logic to container of Dialog instead of putting it inside the dialog
https://codesandbox.io/s/myw173jyq8
hey check this code sandbox for navigation away using react router prompt with custom dialogue.

Where is the best place to show the splash screen using prism 7

I'm new to wpf and prism. I've created a splash window containing a progressbar which it's value is going from 0 to 100 in a backgroundworker.
I don't know where exactly to show the splash screen and close it.
I tried to show the splash before resolving the shell, but it ends up with having splash and shell open together and don't know where to close the splash either.
protected override Window CreateShell()
{
Views.SplashScreen splashScreen = new Views.SplashScreen();
splashScreen.Show();
return Container.Resolve<Shell>();
}
thank you.
As written somewhere else, InitializeModules is a good way to handle the splash screen:
internal class App : PrismApplication
{
// [...]
protected override void InitializeModules()
{
var splashScreen = new SplashScreen( "myLogo.png" );
splashScreen.Show( false );
try
{
base.InitializeModules();
}
finally
{
splashScreen.Close( TimeSpan.Zero );
}
}
}

Go to the specific tab when backed from a screen

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.

Unblock widget without lose focus

I have a focused widget and a blocked widget, when I unblock the blocked widget, the focus is stolen
Look this example (click once on the run button) : http://www.qooxdoo.org/current/playground/#%7B%22code%22%3A%22var%2520field%2520%253D%2520new%2520qx.ui.form.TextField()%253B%250A%250Avar%2520button%2520%253D%2520new%2520qx.ui.form.Button(%2522A%2520button%2522)%253B%250A%250Avar%2520blocker%2520%253D%2520new%2520qx.ui.core.Blocker(button)%253B%250A%250Athis.getRoot().add(field%252C%2520%257Btop%253A%252010%252C%2520left%253A%252010%257D)%253B%250Athis.getRoot().add(button%252C%2520%257Btop%253A100%252C%2520left%253A10%257D)%253B%250A%250Ablocker.block()%253B%250Afield.focus()%253B%250Ablocker.unblock()%253B%22%2C%20%22mode%22%3A%22ria%22%7D
I'm not quite sure that what you try to achieve is what the qx.ui.core.Blocker was intended for. The implementation does not take in account that the focus is moved during the block.
If you call the method block the code tries to determine the widget which was focused before the block is done and saves that widget, then sets the focus to the widget to be blocked and restores the focus to the saved widget when unblocking.
With a small addition in a subclass, you could avoid that focus save/restore:
qx.Class.define("qx.ui.core.MyBlocker",
{
extend : qx.ui.core.Blocker,
properties : {
backupActiveWidget :
{
check : "Boolean",
init : true
}
},
members : {
// overridden
_backupActiveWidget : function() {
if(this.getBackupActiveWidget() === false) {
return
}
this.base(arguments);
}
}
});
and use the blocker this way:
var blocker = new qx.ui.core.MyBlocker(widgetToBeBlocked);
blocker.setBackupActiveWidget(false);
This should prevent the blocker from stealing the focus which may be set during the block.

InteractionRequest<Confirmation>: the focus stays on the clicked button

Would anybody know how do I give the focus to the Cancel button of a Prism InteractionRequest?
What happens at the moment, is that given you've pressed enter on a button in a main window and the InteractionRequestTrigger fired, if you press enter again, you are in trouble as the focus stayed on the parent window and InteractionRequestTrigger fires a second time...
Thanks for your help
Focus on Confirmation dialog should be set automatically after firing the InteractionRequestTrigger.
You may find helpful the following State-Based Navigation Prism Quickstart:
State-Based Navigation
A Raise() method is invoked in the QuickStart for showing the InteractionRequest's dialog at ChatViewModel's SendMessage() method by setting the proper ViewModel context and its callback:
public IInteractionRequest SendMessageRequest
{
get { return this.sendMessageRequest; }
}
public void SendMessage()
{
var contact = this.CurrentContact;
this.sendMessageRequest.Raise(
new SendMessageViewModel(contact, this),
sendMessage =>
{
if (sendMessage.Result.HasValue && sendMessage.Result.Value)
{
this.SendingMessage = true;
this.chatService.SendMessage(
contact,
sendMessage.Message,
result =>
{
this.SendingMessage = false;
});
}
});
}
In addition, the ChatView detects the interaction request and the PopupChildWindowAction displays the SendMessageChildWindow pop-up window:
<prism:InteractionRequestTrigger SourceObject="{Binding SendMessageRequest}">
<prism:PopupChildWindowAction>
<prism:PopupChildWindowAction.ChildWindow>
<vs:SendMessageChildWindow/>
</prism:PopupChildWindowAction.ChildWindow>
</prism:PopupChildWindowAction>
</prism:InteractionRequestTrigger>
I hope this helps.
Ah! I should have marked my Popup as Focusable!

Resources