Copy and Paste to clipboard in Blackberry code - blackberry

I read about a solution to copy and paste a message in Blackberry Code is stack overflow
Can someone please explain the "message to the clipboard" solution in more detail or give some hints about the name of the functions?

They were probably referring to the clipboard class. You can use it to temporarily store text using the put method and then retrieve it using the get method.
EDIT:
Following the first solution proposed in the link you referred to, once you open the native sms application and wait for about a second:
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(sMess));
I believe you can inject the content of the clipboard to the highlighted field, by first getting a reference to the currently focused field:
Field myField = UiApplication.getUiApplication().getActiveScreen().getFieldWithFocus();
Then using the paste method to inject the text from the clipboard.
Hope this helps

as Tamar mentioned, look at the clipboard class to know more about the methods (get set). If you want to do something like "put the content of the clipboard i the focused textfield"? you need to do the following
Create a CustomTextField class which extends TextField
Override onFocus() and onUnFocus() methods. In onFocus() save the contents to textField to the clipboard.

Related

JS callback to Vaadin component

I have a JS component (SigPlot) that I need to read click values from. I have instantiated SigPlot inside of a VerticalLayout, where I also instantiate a DIV to pass to the SigPlot constructor. I am not sure if this is a valid way, but it works.
Now I need to read CLICKS but I am having troubles finding correct way to do this. Can someone pass some words of wisdom?
In my constructor for my VIEW, it use addAttachListener to start my JS code using.
div.addAttachListener(e->{
e.getUI().getPage().executeJs("myInit($0)",div);
});
How can I register a click listener to this?
Regards
As long as it's just a regular DOM event listener, then something like this should work:
div.getElement().addEventListener("click", event -> Notification.show("Clicked"));
If you need to do something on a more granular level, then your might want to expose callbacks as #ClientCallable and then use executeJs to run some short JavaScript snippets to set up listeners that delegate to those methods.

iOS Custom Share Extension get content

I want to create custom share extension and I would like to access to data that I want to share.
So as I read we need to inherit from UIViewController instead of SLComposeServiceViewController to have custom interface.
So with default interface I see this:
How can I get information from context? I mean get link I want to share, and for example image?
I know that there is some extensionContext in SLComposeServiceViewController, but in my case with custom UI I don't have it. In any case how to get that information form NSExtensionContext, because I have print out it in console and there is simple data structure, like we see in JSON or smth like this.
So the question is about getting link from context with custom UI, maybe I am on a wrong way.
The default UIViewController class has an extensionContext property!

Create Header and implementation file in swift

This is more of a coding style question but i believe it is valid. Coming from an obj c background i always create a .h and a .m when creating a class. However with swift that changes and all that goes into a single file. I know that for some people this is cool but i miss having these two things separate.
Quoting a comment from Zaph
"What I miss is a list of public methods as opposed to searching an
entire source file for methods not marked private. There is a
programming concept of "writing to the interface". And the public
methods should be carefully picked, not just because the developer
forgot to make some private."
is there a way to have a header - implementation class in separate files using swift? Maybe some trick?
Thanks
May be you can use Generated Interface to view all the public methods and properties. You can find that option at the bottom of related files popup in the upper-left of the source editor window. To switch back, click Original Source in the same pop up.
Shortcut: control + cmd + down arrow
This is how generated interface file looks.
As far as i'm aware, this cannot be done. That being said, if set out your .swift files correctly then they are still very readable. I tend to follow this as a guideline for styling in swift and i find that it breaks things up into readable sections, especially by using // MARK: as well.
In short, no.. But what do you miss..? Once you get used to it, you will probably prefer it like this! The old separation has no clear advantage over this new one!
More and more languages use this approach, as it reduce coupling and errors.
So when you change the signature of a function, to need to check another file to update it, it's only duplication without any added value.
The problem you describe (how to see only "public" functions) is usually done buy tools( IDE) or documentation generators.
You can create 2 swift files:
YourClassNameHeader.swift
class YourClassName {// put here all your properties
}
YourClassNameMethods.swift or YourClassNamePrivate.swift
extension YourClassName { // put here all private methods and
properties }
But in general its not good practise

JavaFx Label text = variable

I have a JavaFX GUI in an fxml file with its controller class defined. I have two text items that I want in that GUI, one tied to a variable whose value does not change until the user reloads the screen, the other I would think needs to be a StringProperty as it shows the running total of a column in my TableView. Because of what they are, I'm trying to use Label instead of a TextField as their display control.
I liked Sebastian's answer to this problem here:
Displaying changing values in JavaFx Label
however, when I try to use it I get a compile error that says:
cannot find symbol
symbol: variable textProperty
location: variable salesNoLabel of type Label
I'm not sure what I'm doing wrong, but to start with, my label text is initially set in the fxml file, so in my controller I just have its fx:id substituted for "myLabel" listed in Sebastian's answer:
salesNoLabel.textProperty.bind(sn);
where salesNoLabel is the fx:id of the label and sn is a string variable.
Not sure if you need to see more of my code to help me with this problem, but thanks in advance for checking it out.
Sebastian's answer had a syntax error, I edited it to fix it.
You need to invoke the textProperty() method on the label:
salesNoLabel.textProperty().bind(sn);
Note the addition of parentheses after the textProperty identifier to invoke the method.

Syntax Coloring without Presentation Reconciler

I would like to do coloring in Eclipse without using the presentation reconciler. Therefore, first, I need to figure out how to associate a TextPresentation object with either my editor or document, but I am having difficulty finding out how to link it either of those. Normally, the CreatePresentation in the IPResentationReconciler interface would give the style range to the textpresentation, and from there Eclipse would know what to do with that presentation object. Is there some way to use a TextPresentation object without the use of PresentationReconciler? It would be nice if I could do coloring without the use of reconciler. Thank you.
I finally figured out how to achieve the coloring without the use of Reconcilers.
I discovered that first I needed a way to obtain a reference to my SourceViewer object, as I am extending TextEditor. I also discovered that I could implement the TextListener interface and add my own listener to the SourceViewer object. One must be careful, however, as calling the getSourceViewer() method can result in null if not called at the appropriate spot. Originally, I overwrote the init(...) function in my editor class and made the getSourceViewer() call, but it still resulted in null. After doing a bit of research, I discovered that I could properly obtain a reference to the SourceViewer object by overriding the createPartControl method. I first call super.createPartControl(...) and then make a call to getSourceViewer(). After I obtained that reference, I used that with my listener class I created and was able to do the coloring myself with the setTextColor method the SourceViewer object has. Hope this helps others in the same situation.

Resources