.focus and .trigger with text - text

I need help with my script. Need script working like this:
$(".Chat textarea").val(pQ); < .chat textarea [text place], pQ < my text
I want when text add in .chat textarea when add .focus() and press AUTO ENTER.
I think this script must look like:
var e = jQuery.Event("keypress");
e.which = 13; //choose the one you want
e.keyCode = 13;
$(".Chat textarea").val(pQ);$(".Chat textarea").focus();$(".Chat textarea".trigger(e);
I try this but this not work :/

Related

Delete text in textbox without deleting the textbox on canvas in fabric.js

I'm using fabric.js and have IText textboxes on canvas. The user can freely move the textbox around and also edit the text within. How to avoid a textbox being deleted (removed from the canvas) when the user deletes the text using delete key and there's no more text?
Thanks for the response.
deleteText(activeObject) {
var startIndex = activeObject.selectionStart;
var endIndex = activeObject.selectionEnd;
if (endIndex > 0 && startIndex != endIndex) {
var text = activeObject.text;
var newText =
text.substring(0, startIndex) +
text.substring(endIndex + 1, text.length);
activeObject.set("text", newText);
this.canvas.fire("object:modified");
} else {
this.canvas.remove(activeObject);
}
}
have 2 versions of answer
1.Your are deleting textbox using this line of code , try commenting it and see what happens
this.canvas.remove(activeObject);
2.Textbox is not being deleted , you can't see it because of white canvas background and emptiness inside textbox, since there is no text , try mousedowning a canvas and select a big area , check if you are able to select your textbox this way

How Do I Remove a String that I Added Using svg.appendChild?

I am trying to build a program that will take a user input in a text box and display it. My problem is that when I enter a new input into the text box hat input overlaps the first text. What I want is that original text to be removed and replaced by the new input. The code I am using is below.
function eccentricityChanged() {
let svg = document.getElementById('diagram');
let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
text.setAttribute('x', 585);
text.setAttribute('y', 275);
text.setAttribute('fill', 'red');
svg.appendChild(text);
svg.selectAll('*').remove();
let txt = document.getElementById("eccentricity").value;
parseFloat('text', txt);
text.innerHTML = txt;

iTextSharp pdf table cell height issue

I have iTextSharp 5.4.4 (nuget) and have a nice table with a barcode (ean13) and text below it.
I have specific tablecell heights (and cell widths) because I want to print the pdf to an A4 with stickers.
Here is the current layout:
as you can see, there is a rather large gap between the ean13 code and the text below.
here is my C# code:
PdfPCell c = new PdfPCell();
c.FixedHeight = 21.2f * postScriptPointsPerMilimeter; // to get to accurate milimeters
c.HorizontalAlignment = Element.ALIGN_CENTER;
Paragraph p = new Paragraph();
p.Font.Size = 6;
Chunk code = new Chunk(dr["productcode"].ToString());
p.Alignment = Element.ALIGN_CENTER;
p.Add(code);
BarcodeEAN ean13 = new BarcodeEAN();
ean13.CodeType = BarcodeEAN.EAN13;
ean13.Code = dr["ProductEan13"].ToString();
ean13.BarHeight = 4.0f * postScriptPointsPerMilimeter;
var a = ean13.CreateImageWithBarcode(cb, null, null);
a.ScalePercent(90);
c.AddElement(a);
c.AddElement(p);
t.AddCell(c);
My question is to reduce the space between the barcode and the text. I cannot see if it has something to do with the barcode's margins or the paragraph's or maybe both... hard to troubleshoot.
p.Leading = 0;
That was missing. I thought that
p.SpacingBefore = 0;
would do the trick, but it didn't. Leading did!

Removing menu in MFC

In MFC how to remove a menu-item of POPUP type. RemoveMenu() either take ID or position. Since, there is no ID for POPUP menu, option left is by using position.
But I am not getting how and where I can call RemoveMenu().
File Edit Test
Test_submenu_1
Test_submenu_2
Test_submenu_3 > submenu_3_item_1
Test_submenu_4
Test_submenu_5
I want to remove Test_submenu_3? I am not getting how do find CMenu object for Test so that I can call RemoveMenu() by passing position "2" for submenu_3_item_1.
Any suggestion for doing this will be greatly appreciated.
Thanks!
You cannot use LoadMenu, since this function does just that.
After modifying loaded menu it is killed when menu object used to load it goes out of scope. You have to modify menu that is currently used.
Your menu is a popup part of the main menu, second in position. It contains 5 items and second one is another popup. To my understanding, you want to remove this item and popup of this item.
To make it work you will have to ask main window for the current menu:
CMenu* pMenu = GetMenu(); // get the main menu
CMenu* pPopupMenu = pMenu->GetSubMenu(2);//(Test menu with item....)
pPopupMenu->RemoveMenu(2, MF_BYPOSITION);
Of course, this code is from the main frame. If you want to use it elsewhere, you will have to access all using pointer to the main frame.
Try the below. You get the Test sub-menu first (index 2), then once you have that you tell it to remove its Test_submenu_3 submenu by position (also 2).
CMenu topMenu;
topMenu.LoadMenu(IDR_YOUR_MENU);
CMenu& testSubMenu = *topMenu.GetSubMenu(2);
testSubMenu.RemoveMenu(2,MF_BYPOSITION);
'Test' is the 3rd menu item (by position) on the top level menu. It's just been rendered horizontally rather than vertically. Assuming you have a handle to the top level menu use the same code you'd use to the get the sub menus as you would to get the 'Test' menu.
You can use this below code to remove the submenu, by comparing name
bool RemoveSubmenu(CMenu * pMenu) {
for (int pos = 0; pos < pMenu->GetMenuItemCount(); pos++) {
wchar_t *name = new wchar_t[mf.cch + 1];
MENUITEMINFO mf;
ZeroMemory(&mf, sizeof(mf));
mf.cbSize = sizeof(mf);
mf.fMask = MIIM_SUBMENU | MIIM_FTYPE | MIIM_STRING;
mf.fType = MIIM_STRING;
mf.dwTypeData = NULL;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf))
break;
if (mf.hSubMenu != NULL){
mf.fMask = MIIM_TYPE;
mf.fType = MFT_STRING;
++mf.cch;
mf.dwTypeData = (LPSTR)name;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf)){
bRet = false;
break;
}
//
// compare sub menu name (i.e mf.dwTypeData) here, do the required
// modifications
//
pMenu->RemoveMenu(pos, MF_BYPOSITION);
bRet = true;
break;
}
}
}

Flex Buttons from string

I have buttons with id's button1, button2, button3, etc.
I have a for loop that i need to loop starting with a number and i need to enable buttons based on my loop. I need help taking my string button1 and making that the id "button1" so i can use the button property's.
Any help would be greatly appreciated.
Thanks!
You should be able to iterate as such:
for (var i:uint = 1; i <= 3; i++)
{
var element:IVisualElement = this["group" + i];
}
You don't denote whether this Spark or Halo, but clearly substitute IVisualElement with the type of your choice. (Button, UIComponent, DisplayObject...)

Resources