I'm trying to build a web app with Dart and HTML. I have a HTML input field
which receives type text. I would like to process the text the user inputs as it inputs each letter, not only when it hits ENTER or something like that.
I currently came up with this solution in Dart but it only prints the user input when it hits ENTER which is not what I'm looking for as said.
import 'dart:html';
void main() {
TextInputElement text = querySelector("#input-text");
text.autocomplete = "asas";
text.onChange.listen((data) {
parent.appendHtml('<p>${text.value}</p>');
});
}
I looked up some topics like Futures, Streams and Broadcast streams but it doesn't look like what I need still.
If someone could help it would be great!
Onchange will only work that way because it listens to submit events.
What you can do instead is listen to input field .onKeyUp event.
Everytime inside the input field if you type and the moment you release your key this event will be registered and listeners will be invoked
https://dartpad.dartlang.org/02e27326c073de360f14bb9a9726f1c9
You can see this example on dart the moment you type something it get's printed.
Here onKeyDown on onKeyPress can also be used but the thing is if the user keeps the key pressed it will register all of those events creating n number events
Related
Sadly, I don't find any focus event for sap.m.Input or sap.m.TextArea to which I can register handlers in XML view.
What are your best practices e.g. if you have nearly 100 fields and most of them should handle focus event so that the text within the input field gets automatically selected?
Normally, I try to avoid to register the focusin handler in controller on every input field (also looping) but it seems that there are no other possibilities available isn't it?
What I want is a possibility, that when I navigate e.g. with keyboard through a table with input fields, every time when I press the tab or updown arrow keys to jump to next input field, the whole content of the input field should be selected.
Example:
Open this table sample.
Click on Edit.
When tabbing, it automatically selects the text. But it doesn't work with updown arrow keys and with sap.m.Input class.
Here is a working example of an extended sap.m.Input that selects the text on focus: https://embed.plnkr.co/98BIbMEIujbzBXqU
Input.extend("demo.control.Input", {
onfocusin: function() {
if (typeof Input.prototype.onfocusin == "function") {
Input.prototype.onfocusin.apply(this, arguments);
}
this.getDomRef("inner").select();
},
// ...
});
Note: sap.m.InputBase provides the API selectText(iStart, iEnd). However, that API doesn't support Input controls with type Number according to the HTML spec as well as API reference:
selectText
Only supported for input control's type of Text, Url, Tel and Password.
Since our goal is to select all text within the input field (not a range) regardless of the type, domElement.select()api can be used instead.
If you really have a form with -- gasp! -- 100 fields, I would then extend the standard sap.m.Input and attach the onfocus browser event in that extended control using sap.ui.core.Control's attachBrowserEvent method.
I am using CAPL to simulate a test envirmonet for some small tests and i am having problems sending messages or more specific setting up the values.
I am able to read Signal Values with $SignalName, also i am able to set signal values like that.
If i am using this code to send a message the message data is always 0:
on key 't'
{
message MessageName msg;
setSignal(SignalName,i);
write("Value: %d",i);
outport(msg);
}
Witch makes kinda sence becouse i think the message objects are intended to be used to send bytes witch you can access through msg.byte()
I know that i can set signals in messages by msg.SignalName, but again this seems not the right way. I think there should be a way to send a message and all the signals contained in the message are set to the values set by SetSignal() function. Otherwise the SetSignal Funktion is a bit useless
Maybe somebody has an idea.
Thank you
I am using CANalyzer version 8.2 and I do not have the option to use SetSignal(signal, value) function. Setting the signal values by accessing the message selectors seems to be a reasonable approach. However you used the function outport! You need to use the output function to transmit messages.
on key 't' {
message MessageName msg;
msg.signal1 = value1;
output(msg);
}
For this method the database has to be configured so that the message msg contains all the necessary signals (signal1).
If you want to set all signal values to the start values configured in the database use the function:
setSignalStartValues(message msg);
You can set up an interaction layer that will handle the messages as defined in the CAN database (DBC file) assigned to the node. The interaction layer will need some attributes in the database to define how the messages have to be sent. If not already present you may have to add these attributes. If the Tx messages are not sent as expected, check the attributes.
Function output() is useful if you want to implement (and fully control) the sending of the message yourself.
Instead of using SetSignal() it is also possible to write the signal using $SignalName = value;
See this support note:
https://kb.vector.com/upload_551/file/SN-IND-1-011_InteractionLayer(1).pdf
You may have to guess and experiment a bit. In the DBC files provided by a customer I found attribute values that are not mentioned in this document.
I'm having a great time playing around with knockout js and have just started to get to grips with adding custom bindingHandlers.
I'm struggling a bit with the update function of a 3rd party jqWidget gauge - I can only get it to animate the first time I update the variable. On each update after that it just sets the value directly.
I don't fully understand ko.utils.registerEventHandler() and what it does although I've seen it in a bunch of other examples. Is this what is causing the animation to break? How do I know which events to register from the 3rd party widget?
For some reason this works fine if I add a jquery ui slider that is also bound to the observable.
You can test this here: set the value a few times to see that it animates the first time and not after that.
http://jsfiddle.net/LkqTU/4531/
When you update the input field, your observable will end up being a string. It looks like the gauge does not like to be updated with a string value, at least after the first time.
So, if you ensure that you are updating it with a number (parseInt, parseFloat, or just + depending on the situation), then it appears to update fine.
Something like:
update: function(element, valueAccessor) {
var gaugeval = parseInt(ko.utils.unwrapObservable(valueAccessor()), 10);
$(element).jqxGauge('value', gaugeval || 0);
}
http://jsfiddle.net/rniemeyer/LkqTU/4532/
You would generally only register event handlers in a scenario like this to react to changes made by a user where you would want to update your view model data. For example, if there was a way for a user to click on the gauge to change the value, then you would want to handle that event and update your view model value accordingly.
I'm answering the
I don't fully understand ko.utils.registerEventHandler() and what it does
part of your question.
registerEventHandler will register your event handler function in a cross-browser compatible way. If you are using jQuery, Knockout will use jQuery's bind function to register the event handler. Otherwise, will use the browser Web API with a consistent behavior across browsers.
You can check it out on the source code.
I am working on a custom email notification for a WSS 3.0 solution. I am using a custom class inheriting from IAlertNotifyHandler to generate the email. There is a great example here that shows how this is done for an Immediate alert. Here is some of the code related to the SPAlertHandlerParams, which is used to get information about the alert and the item that triggered the alert.
SPAlertHandlerParams ahp;
int id = ahp.eventData[0].itemId; //gets the itemId of the item triggering the notification.
SPListItem myItem = list.GetItembyId(id);
For immediate alerts, this works great as the item I want is always at the [0] position of the eventData object. For a digest event, I thought I could just loop through all of the items in the ahp.eventData. Two problems with this.
First, it gives me all of the events where it is sending notifications, not just the ones for me. Second the eventData[0].itemId no longer points to a valid id on the list. It is 6-7 digit number instead of a 3 digit number.
Does anyone know the correct way to get to the alert information for digest emails?
Please let me know if you have any additional questions about this.
Thanks for your help!
For my project, I created a custom timer job (using the post by Andrew Connell) that mimics the Alert functionality. It runs overnight and queries for any users subscribed to my list with daily alerts. It then packages all of the new tasks into a custom email message.
I left the custom alert in place to suppress any daily notifications from the system. I just return 'True' so that alerts are not sent for tasks assigned to only 1 person. I suppose looking back on this, I could have run the query code in the custom alert and not need a separate timer job.
I would like to use Jquery's UI autocomplete but with some additional functions: after user selects suggested item, I would also like to display additional data related with that item (for example if database of contacts are being searched, then I'd like to display contact's email, addres...) in some html element.
Is there a way to accomplish this?
Thanks in advance,
Ile
EDIT:
I'd like to provide more detail description of what I actually need:
When user starts searching contacts, as a result from database I would like to return contact's ID and Full Name. After user selects certain contact, then ajax function is called and it retrieves all details from selected contact using it's ID. But I don't know how to do following:
As a result from database return the ID and Full Name of contact as a JSON result (probably I would find the solution to get the right format, but I don't know how it needs to be passed to Autocomplete script)
How to handle the result data so that I display only full name and ID is used only when certain contact is selected, so that I can retrieve full details of certain contact
Have a look at its events: You can add a handler for the select event and display all your informations once it fires.
You can specify extra data in formatMatch function. The parameter must be some delimiter separated string. Later in .result function , which takes 3 arguments [event, data, formatted], you can retrieve it by splitting the formatted by the delimiter use and populate the required values.