I want to achieve a functionality in which, if I click on the canvas, a textbox should appear. After entering the text and click save button, it should save that text on a canvas. Again if I click on canvas somewhere else, it should again add a new textbox. In short, I want to add a new text box on click of canvas and want to save the textbox value.
Give me any good reference where I can learn canvas. I am asking for good tutorial in order to achieve specified functionality.
You can give coordinates of canvas or id where you click. Also have a variable to set it as {0 if text box available, so have to save. 1 if text box not available so have to add text box}. Swap them and add text box or save them accordingly.
If you have a large are where you have to find clicked or not, you can add as
$("#canvasid").click(function(){
var $this = $(this);
if($this.data('clicked')) {
var table = $(this).closest('sometablewhereiwanttextbox');
if (table.find('input:text').length < 7) {
table.append('<tr><td style="width:200px;" align="right">Name <td> <input type="text" id="current Name" value="" /> </td></tr>');
}
});
Alter the code as needed.
Saving to DB depends on the technology you use. If its MVC or asp.net, then use AJAX calls to pass the data to back end and save them using web method.
Related
In ASP.NET Core I have a home page that I would like to add a 'notes' section to, that anyone can append to. On the page I have this
<p id="noteSection"></p>
<textarea row="6" cols="66" id="note" value="message"></textarea>
Save
<script type="text/javascript">
function SaveNotes() {
var value = document.getElementById('note');
$('#noteSection').text(value);
}
</script>
What am I doing wrong? How can I allow for any user to input a note into the text area, click save, and have that text save into the <p></p> indefinitely? I want it to save even if a user logs out it will still be appended in the html upon relogging in? I would prefer not to have to create a table for this,.
Why wouldn't you create a table for it tho? If you want to keep it forever you need a away to persist the values. The only other option I can think about would be to use localstorage or cookies
Here is the link for an example of the issue I will attempt to describe. In the chips autocomplete example, click the text box to select a new fruit.
Now, before clicking anywhere else, click again on the text box as you did before.
This should result in no options showing up. The issue here is that the user must either begin keying in a new selection or first click another element in the window before matchip will show the options to choose from. I am wondering if there is a way to fix this issue. I would like a user to be able to choose a selection from the list and then immediately click the text box as they had before and make a new selection.
I'm using mat-chip-list inside an outer *ngFor iterating over a FormArray.
Here is what I'have done. It's pretty efficient :
<input
#validatorInput
#operationTrigger="matAutocompleteTrigger"
[formControl]="contactCtrl"
[matAutocomplete]="auto"
[matChipInputFor]="chipList"
(blur)="contactCtrl.setValue(''); validatorInput.value='';"
(click)="contactCtrl.setValue(''); validatorInput.value=''; operationTrigger.openPanel()">
The trick is
Always clear your html input and your (shared) formControl with an empty and not null value each time the blur and click events occur.
Do NOT do this 'clear' on the input focus event. (Because when you delete the last chip, the input is auto-focus and you will have the famous Expression has changed after it was checked.
Call operationTrigger.openPanel(); when the user click on the input
Setting contactCtrl.setValue(''); allows your autocomplete panel to be automatically opened when you call operationTrigger.openPanel()
Setting validatorInput.value=''; is just a way to properly sync your formControl with the html input to ensure a good UX/UI behavior.
Inside my formArray, the formControl is the same for all the inputs but it does not matter since the user can only manipulate one input at a given time
Since you didn't post your code and you mention the example on the material site I'm going to do it as a fork of the stackblitz example they have on their site.
But this will allow you to open the autocomplete panel again despite having had the cursor there and choosing an option previously.
// Using MatAutocompleteTrigger will give you access to the API that will allow you to
// to open the panel or keep it open
...
#ViewChild(MatAutocompleteTrigger, {static: false}) trigger: MatAutocompleteTrigger;
...
ngAfterViewInit() {
fromEvent(this.fruitInput.nativeElement, 'click')
.pipe(
tap(() => {
this.trigger.openPanel()
})
).subscribe()
}
Link to the full stackblitz:
https://stackblitz.com/edit/angular-sb38ig
I need that when a user click a button. The dress changes. There are separate files for the dress and the body.
I added a custom code on a tap/click event on GWD which is this
document.getElementById("body").src = "Skin-Fair(Ivory).png";
document.getElementById("body").source = "Skin-Fair(Ivory).png";
What happens is that there is a placeholder when I click the button but it never makes the intended image appear.
This is a minimum example of how to change an image source with a button.
I strongly recommend you take a basic web dev course: https://github.com/bmorelli25/Become-A-Full-Stack-Web-Developer
document.getElementById('bt').addEventListener('click', function () {
document.getElementById('im').src = 'https://placeholdit.imgix.net/~text?txtsize=18&bg=FF6347&txtclr=ffffff&txt=New-Image&w=250&h=50';
});
<button id="bt">Button</button>
<img id="im" src="https://placeholdit.imgix.net/~text?txtsize=18&bg=FF6347&txtclr=ffffff&txt=Placeholder-Image&w=250&h=50">
No coding skills required for that using GWD.
I assume you have imported all your images in GWD project.
You should use the timeline and create two different keyframes.
Set the opacity to 0 to hide the unwanted assets in your keyframes.
Add an event on tap/click and set it to go to the keyframe/page you want.
I have with me the canvas speedometer zip file. My intent is to read, from a text file a single number, and accordingly move the needle on the canvas speedometer as per the number read.
I have tried a few things and all I have managed to do is clunk up things a bit further. Any simple way to get around this, please? Preferably, editing the speedometer.html file such and adding a single button that reads the number from the text file and populates it in the text area provided on the speedometer web page?
Please help.
Edit 1: My bad. I should have included the piece of code I fidgeted around with for a brief while. Here goes the javascript snippet:
function func1()
{
var fileToLoad = document.getElementById("fileToLoad").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var textFromFileLoaded = fileLoadedEvent.target.result;
document.getElementById("maxvalue").value = textFromFileLoaded;
};
fileReader.readAsText(fileToLoad, "UTF-8");
}
And here's the bit about the 'Extract Value' button:
<input type="file" id="fileToLoad">
<button onclick="func1()">Extract Value</button>
The issue is I am getting sort of a clunky page. One which has a choose file button, and the 'Extract Value' button. And then, there are the begin and start buttons defined in the canvas speedometer API. All I am asking is this: is there a way by which I can have a single button on the page on clicking which the data (a single number) present in the text file gets populated on the ext field in the speedometer web page. This is all I want.
And in case anybody is wondering what the speedometer thingy is, please look here:
{http://www.uibox.in/item/68}
Apologies again for leaving a clearly vague question.
I want to know the custom shape creation in html5 using LimeJS.Could anyone tell me how to create a custom shape like comment in a game using LimeJS for html5.
for images
var gameMap = new lime.Sprite().setSize(400,300).setFill('images/bk.jpg').setPosition(0,0).setAnchorPoint(0,0);
for custom shapes we have to fill with different points
You essentially create a custom sprite, and render the UI appropriately, which could be a combination of elements. The shell needs to be:
test.board = function() {
goog.base(this);
}
goog.inherits(test.board, lime.Sprite);
Text input isn't direct; here is an article on text input: https://groups.google.com/forum/?fromgroups=#!topic/limejs/txaxgK3eXQg. You can use a label, and attach to the key press event. I don't know if this works for canvas rendering...