I have used the following code for showing the smiley in uitextfield.
stringWithSmiley = [stringWithSmiley stringByReplacingOccurrencesOfString:#":)"
withString:#"\ue415"
options:NSCaseInsensitiveSearch
range:range];
I searched and found that every smileys/emoji icons has its own id,based on that we can show it on the text field.
My doubt is:
Is that possible to create custom smileys ?If yes ,then how we can show it in the textfield?
If any body has idea then please help me.
Thanks in advance
Try this :
- (BOOL) textField: (UITextField *)theTextField shouldChangeCharactersInRange: (NSRange)range replacementString: (NSString *)string {
NSRange range = {NSNotFound, 0};
NSString *s = #"This is a smiley :)";
range.location = 0;
range.length = [s length];
s = [s stringByReplacingOccurrencesOfString:#":)"
withString:#"\ue415"
options:NSCaseInsensitiveSearch
range:range];
}
Related
I would like to format the text in my discord bot's message, but unfortunately it doesn't work:
var string = "```Questionnaire\n${topic}```";
${topic} - can't topic, but only it works:
var string = Questionnaire\n${topic};
My problem is that i can't enter the text into the table, i want to get topic in box (```)
var string = "```Questionnaire\n${topic}```"; // this don't work
This should do it:
var topic = "in the box";
var string = `\`\`\`
Questionnaire
${topic}
\`\`\``;
How to get the cursor position(top, left) value in Draft.js. I have already seen this question, but it gives only the line number, but I want the top, left value.
This is working for my needs (NB: not tested on multi-platform/multi-browser, but at least it works great on Chrome/Firefox on Windows). The idea is to consider the caret as a mere window selection, and not as a draftjs selection. Hope it'll help.
function FindCaretPosition() {
let selection = window.getSelection();
let selectionRange = selection.getRangeAt(0).cloneRange();
selectionRange.collapse(false);
//-----
let caretMarker = document.createElement("span");
caretMarker.id = "__caret";
selectionRange.insertNode(caretMarker);
let caretPosition = document.querySelector("#__caret").getBoundingClientRect();
//-----
selectionRange.deleteContents();
return { x: caretPosition.left, y: caretPosition.bottom }
}
editorState.getSelection().getAnchorOffset();
you can get the position of cursor like that
How do I get the text from the li tag? I want to find the text "Password is required." only, not the text inside strong tag.
<li><strong>Error:</strong> Password is required.</li>
You need to show your code for somebody to give a complete answer. I guess that you already know how to do something like the following
WebElement something = driver.FindElement(By.CssSelector(?))
string s = something.Text;
The next bit seems to be where you are stuck. There you need to parse the string s. That is nothing to do with Selenium-Webdriver. You could do something like
string[] s2 = s.split(new string[] {">","<"});
were the last element in s2 would be your answer here. This would be totally non generic though. Is this a situation in which you always want to purge html?
Here is the method developed in python.
def get_text_exclude_children(element):
return driver.execute_script(
"""
var parent = arguments[0];
var child = parent.firstChild;
var textValue = "";
while(child) {
if (child.nodeType === Node.TEXT_NODE)
textValue += child.textContent;
child = child.nextSibling;
}
return textValue;""",
element).strip()
How to use in this:
liElement = driver.find_element_by_xpath("//li")
liOnlyText = get_text_exclude_children(liElement)
print(liOnlyText)
Please use your possible strategy to get the element, this method need an element from which you need the text (without children text).
Hello I apologize in advance for my question which I'm sure is pretty basic.
On a map are set 33 landmarks with an array calling a class in the library.
A second array defines the coordinates of those landmarks.
for (var i:uint = 0; i < 33; i++) {
mark[i] = new landMark();
landMarks.addChild(mark[i]);
mark[i].x = lmxy[i]['x'];
mark[i].y = lmxy[i]['y'];
}
var lmxy:Array = [{x:1620,y:880},{x:1850, y:1050},etc...];
So far so good, the landmarks show each in its right place.
The third array contains different legends supposed to show when a landmark is clicked.
So the landmark [1] should show the legend [1] and the landmark [31] the legend [31]
var lgd:Array = [lgdA, lgdB, etc... ];
var legends:MovieClip;
for (var j:uint=0;j<lgd.length;j++) {
legends = new lgd[j]();
legends.x = 300;legends.y = 170;
}
Edit cause obviously that was unclear :
I tried that in the loop to link the marks to the legends but I get an error :
mark[i].addEventListener(MouseEvent.CLICK, getLgd);
function getLgd(e:Event):void {stage.addChild (lgd[i]);}
Any help would be very welcome !
The problem is that the variable i doesn't have a definition. The only way for you to find out which of the landmarks were clicked is to find its index in the array, then you can add the legend that has the same index. Because the index isn't passed from the event listener, you need to use e which has the target property.
This should do the trick:
mark[i].addEventListener(MouseEvent.CLICK, getLgd);
function getLgd(e:Event):void
{
var i:int = mark.indexOf(e.target);
stage.addChild(lgd[i]);
}
since a few hours i'm trying to implement the twitchAPI in my cake projet. a long time ago i made this little script in basic php.
$channelName = "gamespot";
$json_file = #file_get_contents("http://api.justin.tv/api/stream/list.json?channel={$channelName}", 0, null, null);
$json_array = json_decode($json_file, true);
#$json_array[0] && $json_array[0]['name'] == "live_user_{$channelName}";
#$title = $json_array[0]['channel']['status'];
#$game = $json_array[0]['meta_game'];
#$chanel_view = $json_array[0]['channel_count'];
#$totalchanelview = $json_array[0]['channel_view_count'];
but i don't know how to add this lines on my controller
For know i've just find this
public function twitch() {
$json = file_get_contents('http://api.justin.tv/api/stream/list.json?channel=manvsgame');
$twitch = json_decode($json);
$totalchanelview = $twitch[0]['channel_view_count'];
$this->set('twitch', 'totalchanelview');
}
but of course i've this error
Fatal error: Cannot use object of type stdClass as array in /Users/*/Desktop/Websites/**/app/Controller/UsersController.php on line 29
anyone can explain to me how i can use this API?
thanks in advance and have a nice day/night :)
okey first thanks to help me. i still have a little "logic problem"
my function is something like that:
public function twitch() {
$json = file_get_contents('http://api.justin.tv/api/stream/list.json?channel=gamespot');
$twitch = json_decode($json, true);
$this->set('json', $twitch);
}
but know, what can I write to my view to see my informations (like the title of my stream for exemple.
I test with
echo $twitch[0]['title']; (it's my line 1)
bit i've this error
Notice (8): Undefined variable: twitch [APP/View/Users/admin_dashboard.ctp, line 1]
$twitch = json_decode($json, true); // add true param
$twitch[0]['channel_view_count'];
adding true returns the data as an associated array instead