Swift Playground force next page - ios

I'm developing a Playground with many widgets and one of these is a button. The function of this button is force to change to the next page. Is it possible?
I only found the next markup comment for go to the next page and need to render the playground for do it. This isn't useful for my project.
//: [Next](#next)
Thanks in advance,
Best.

No, it's not possible. The whole idea of a Playground (book) is to let the user turn the page for himself, it means you can't do it by code.
Also, it would be a bad practice. Each page should consist of a single experience with an explanation, maybe a goal to achieve, and then the user will turn the page whenever he wants.

Here is a way: PlaygroundPage.current.navigateTo(page: .next)
You also can use .previous and .pageReference(reference: String)
And here is how I use it:
//#-hidden-code
import PlaygroundSupport
if assessmentPassed {
// Actually if you force navigate to the next page you don't really need assessment as it will not be shown
PlaygroundPage.current.assessmentStatus = .pass(message: "Great! Let's go to the next page...")
PlaygroundPage.current.navigateTo(page: .next)
} else {
PlaygroundPage.current.assessmentStatus = .fail(hints: ["Here goes hint"], solution: "Here goes solution")
}
//#-end-hidden-code

Related

Detecting and pasting cntrl+v in Electron

I'm trying to make an electron application that changes what's on your clipboard.
So for instance, when you do "cntrl+v" 2 times in a row it'll display 2 different words.
Is there a way to do this? Since when you use globalKeybinds, it doesn't paste anything when you press cntrl+v.
Thanks in advance.
There can be a work around to this that i have implemented in one of my project.
what you can do is register a global shortcut something like this and call a function to write the desired text to the clipboard.
it's not the elegant way at all since it required 2 key presses but that's what i came up when i worked on it.
globalShortcut.register('CommandOrControl+1', () => {
trigger_paste(1);
});
function trigger_paste(index) {
let tuple=list[index]
clipboard.writeImage(nativeImage.createFromDataURL(tuple.buffer));
}

else statement need to be added in watson conversation dialog

Need help for adding else condition if the input answer is not correct.
Please find the screen shot of If statement I have added.
Sample_Condition
I think you can't put the else because it's just another intent.
So you could just create another node with an IF test corresponding to the ELSE you want to write.
I can't give you the extract but I hope this screenshot will help you.
This is a small test case for a virtual assistant helping you to do simple banking tasks.

How to know DialogResult with ReportViewer.PrintDialog()

I have encountered this problem a lot of times on the internet, but didn't find a good way to fix this.
What I want is to print a report from the ReportViewer control, and if it has been printed, I need to change some stuff in the database (like the user that printed, what time the reports has been printed).
Now I used the reportViewer.PrintDialog() method (which prints fine) but I can't figure out a way to learn if the user actually printed the document, or cancelled the PrintDialog box.
I also tried the System.Windows.Controls.PrintDialog() which does return a DialogResult, but I couldn't find a way to set the reportViewer's report as the PrintDocument's source.
Has anyone of you found a way to do it?
Thanks in advance, and more info/code can be provided if asked.
Oh
If it's C#
Dialog boxes return a value of type DialogResult
so something like
if (System.Windows.Controls.PrintDialog().ShowDialog() == DialogResult.OK)
{
// Mark item as Prionted by User U
}
In VB.NET, try the following:
If reportViewer.PrintDialog() = Windows.Forms.DialogResult.OK Then
'Put your stuff here
End If

Why can't I set a breakpoint in a ASP.NET view?

If I set a breakpoint in the compiled code (for instance in an action), I can then step through, and eventually am stepping through the generation of the View.
I've found this useful a couple of times, but it's tedious as you have to step through a lot of code to get there.
However, I can't set a breakpoint in view. I just receive the message 'This is not a valid location for a breakpoint' from VS2008. Why is this?
Right click on the code you want to break on and go to "Breakpoint -> Insert Breakpoint".
Why? Must have something to do with the face your not working with a pure code file and hitting the left sidebar doesn't know which block of code to use.
Another thing that comes to my mind is to use the debugger; keyword in the view, though I am not 100% sure it will work as in ASP.NET ajax site.
Click to the code where you want to debug and than press F9.
UpTheCreek,
Not really a 'nice' way to do it, however, you can insert some 'flip-flop' code in your view that CAN have a breakpoint placed in it and then step from there. This code doesn't neccessarily have to perfom a function (tho obviously, would be useful if it did).
anyway, you don't want the crumbs, so here's the (meal) deal:
<%
int rspId = 0;
string uniqPageId = Guid.NewGuid().ToString().Replace("-", "");
%>
then, simply place the breakpoint at the side of any of those variable definitions.
Not clean and definately a 'jfar' markdown candidate :-)

How can I prevent the user from navigating back to a previous page?

I have an ASP.NET MVC application, with three views: view1, view2, view3. The logic way for the user to navigate through these is: view1 -> view2 -> view3.
When the user reaches view3, then I must prevent them from loading view2, even by using the "Back" button in their browser.
What is a good, browser-independent means of implementing this?
In most of the applications you have to cope with the back ability from the browser. The user is used to it and he wants to use it and he more or less will hate pages that try to trick them when going back and forward.
Don't try to fool you user think about what he wanted to do and then try do deliver a not completely broken page.
Add a check of referrer page on page load in your application and then show a page or redirect user back to used view. You cannot manipulate or disallow basic navigation on client, but you can solve this problem server-side
I can't comment on the earlier posts, but note that some browsers don't pass referrers, and thus the earlier solution would break (throw an exception, actually).
There are two steps to this:
1) You have to prevent browser-side caching. If you've got a three step process that the user walks through and it's dynamic, you're probably already doing this. If you don't prevent caching, the back button will show the cache of view1. Since step 2 is done server-side, the server won't have a chance to do anything.
2) You need to, as previous poster's have said, do something on the serverside to prevent the display. There are two ways to do this (despite my really bad pseudo code).
a) The quick & dirty way is based on the referer. For example, you'd put the following check on the controller for view2:
if (request.urlreferrer.absolutepath == "controllerview1")
{ //good }
else
{ //bad }
Also, in the case of "bad", you'll have to consider what to do. If you're using forms to pass values back and forth, you've suddenly lost when the user goes back to view2.
Note, though, that some browsers don't ever pass referrers and the above check won't do any good (and request.urlrefferer will be null). (I believe this is generally due to firewalls.) In which case you'd have to do:
b) I've done something like this before. The controller view1/2/3 is essentially a wizard where they're walking through the system. Each controller updates the db row associated with the wizard. So, view 2 would do something like:
if (dbrow.last_saved_page_num == 1)
{ // good }
else
{ // bad
redirect("view" + dbrow.last_saved_page_num + 1);
}
That is outside of the scope of javascript, and cannot be disabled (though you can tell the browser to go forward or back, you cannot prevent it). You would need a server side solution to disallow access to the pages.
There is no JavaScript solution, it would have to be implemented server side.
You can add a function to view1 and view 2 that fires on page load, if you use jquery something like :
$(document).ready(function(){ window.history.forward(); });
or you could just just do this
<html onload="window.history.forward()">
Either way will do pretty much what you want, but maybe not be the best solution in terms of user experience - but if its all you have to work with then it might be the best solution.

Resources