How to invoke an event when a text box loses focus in nsis - textbox

I want to invoke an event when the text box loses focus in nsis installer,so that I can execute a functionality when the event in invoked.

nsDialogs does not support this event, you would usually use the OnChange event to update other parts of the UI.
If you absolutely have to do this you can use a timer:
!include LogicLib.nsh
!include nsDialogs.nsh
Page Custom MyPageCreate
Page InstFiles
Var MyEdit
Var LastFocus
Function MyEditLostFocus
System::Call KERNEL32::GetTickCount()i.r0
SendMessage $9 ${WM_SETTEXT} 0 "STR:MyEditLostFocus, tick=$0"
FunctionEnd
Function DetectFocusTimerHack
System::Call 'USER32::GetFocus()i.r0'
${If} $0 <> $MyEdit
${AndIf} $LastFocus = $MyEdit
Push $0
Call MyEditLostFocus
Pop $0
${EndIf}
StrCpy $LastFocus $0
FunctionEnd
Function MyPageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateText} 0 30u 100% 20u "Hello"
Pop $MyEdit
${NSD_CreateText} 0 60u 100% 20u "World"
Pop $9
${NSD_CreateTimer} DetectFocusTimerHack 333
nsDialogs::Show
FunctionEnd

Related

WM_KEYDOWN in WndProc - doesn't trigger

I am trying to capture WM_KEYDOWN to process some keyboard events at the Form level. I know I can use KeyPreview=true and use the OnKeyDown event of TForm. However, I'd like to do it in the WndProc() to simplify event processing in a single function. The problem is, it doesn't fire in the WndProc(). Is there a particular reason why it doesn't? Aside from using BEGIN_MESSAGE_MAP to handle WM_KEYDOWN, is there another way?
void __fastcall TForm1::WndProc(TMessage &fMessage)
{
switch (fMessage.Msg)
{
default: break;
case WM_KEYDOWN: {
TWMKeyDown KDMsg = reinterpret_cast<TWMKeyDown&>(fMessage);
TShiftState KDSs = KeyDataToShiftState(KDMsg.KeyData);
if (KDMsg.CharCode == 'C' && KDSs.operator ==(TShiftState() << ssCtrl))
{
// Process CTRL+C key
fMessage.Result = 1;
return;
}
}
break;
}
TForm::WndProc(fMessage);
}
Keyboard (and mouse) messages are posted to the window that has input focus. If a TForm has a child control that has the focus, the messages will go directly to the child's WndProc, not the Form's WndProc.
That is where KeyPreview comes into play. When true, it tells child controls to forward their keyboard messages to their parent TForm for processing.
Otherwise, you can alternatively use the TApplication(Events)::OnMessage event to handle input messages before they are dispatched to their target windows.

Close the agm-info-window when mouse clicked out of the info-window in angular 7

I'm working with angular-google-map.when marker is clicked info-window will open and hides previos window when other marker is clicked.now I want to close the info window when mouse clicked on map .
<agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom" [styles]="styles" [disableDefaultUI]="false" [zoomControl]="true"
[scrollwheel]="false" [streetViewControl]="false" [fitBounds]="false" (zoomChange)="onagmZoomChange($event)">
<agm-marker *ngFor="let c of markers; let i = index" (markerClick)="clickedMarker(infowindow, i)" [latitude]="c.location_details_lat"
[longitude]="c.location_details_lon" [iconUrl]="m.icon">
<agm-info-window #infowindow [maxWidth]="320" >
<div class="info-header">
<h2>add: {{ c.add }}</h2>
</div>
</agm-info-window>
</agm-marker>
</agm-map>
Add a handler for the mapClick event on the AgmMap that checks if you have an open info-window, and if you do, close it. Since you have already implemented a handler to have only a single info-window open, you probably have a variable holding the window that is open, something like:
private singleInfoWindow: AgmInfoWindow = null;
Your handler for the AgmMap mapClick event can close that infoWindow:
if (this.singleInfoWindow) {
this.singleInfoWindow.close();
this.singleInfoWindow = null;
}
Best solution is to use the closeOnMapClick property option on your instance of snazzy-info-window:
[closeOnMapClick]= "true"
This is taken from documentation of closeOnMapClick, where you can read further: https://github.com/atmist/snazzy-info-window#closeonmapclick

Roblox studio how to detect key inputs?

I am trying to make a GUI that toggles on key input and i have already looked at the roblox wikipedia and a question that is supposedly what i am asking however it doesn't seem to work. Roblox Studio - Key Toggle for GUI
I have got no code because i completely don't understand ContextActionService so sorry.
In order to toggle a GUI on and off, you just need a reference to the UIElement and you can set its Parent value. ContextActionService:BindAction just allows you to bind the action to some kind of input.
Here's a simple example that is a little more explicit than the one in the linked question.
Make a LocalScript in StarterPlayer > StarterCharacterScipts, add this code
-- make a simple GUI to show off
local targetGui = Instance.new("ScreenGui")
local label = Instance.new("TextLabel", targetGui)
label.Text = "Hello World"
label.Position = UDim2.new(0, 0, 0, 0)
label.Size = UDim2.new(0, 200, 0, 30)
-- choose where to make the gui
local targetParent = game.Players.LocalPlayer.PlayerGui
-- make a function for handling key presses
local function handleKeyPress(actionName, inputState, inputObj)
-- DEBUG : show the information for this keypress
print("Handle Key Press")
print("Action Name : ", actionName)
print("Input State : ", inputState)
print("Input Obj - KeyCode : ", inputObj.KeyCode)
print("")
if inputState == Enum.UserInputState.End then
if targetGui.Parent then
targetGui.Parent = nil
else
targetGui.Parent = targetParent
end
end
end
-- connect that function to ContextActionService
local createDedicatedButtonOnMobile = false
game.ContextActionService:BindAction("toggleGui", handleKeyPress, createDedicatedButtonOnMobile, Enum.KeyCode.R)
Now whenever you press R it will parent or unparent the gui element. Now you've got a toggle.
BindAction is a very flexible function, so there isn't just one way to do this stuff. In this example, when you press R, you will see handleKeyPress fire a few times. Its output should look something like this :
Handle Key Press
Action Name : toggleGui
Input State : Enum.UserInputState.Begin
Input Obj - KeyCode : Enum.KeyCode.R
Handle Key Press
Action Name : toggleGui
Input State : Enum.UserInputState.End
Input Obj - KeyCode : Enum.KeyCode.R
This is because a key press has two states, one when you press the key down, and one when you lift the key up. The example function listens for when you lift up your finger before executing the toggle.
Hope this helps, let me know if you are still stuck.

How do I prevent a click event based on drop down list selection?

I have a drop down list in an ASP.NET project with four options and a default state. There is also a button that opens a popup dialog. I would like to disable the button that opens the popup if user selects certain options, as certain options on the ddl do not require the popup dialog. The popup is called via onClick event that is tied to the image. How do I block the onClick event from firing for two of the four ddl options? Here's a simplified version of the code:
HTML STRUCTURE:
<select class="selClass" id="selID" name="selName"><option value="">- Select -</option>
<option value="Option1">Option1</option>
<option value="Option2">Option2</option>
<option value="Option3">Option3</option>
<option value="Option4">Option4</option>
</select>
JQUERY:
$(function () {
if ($("#ddlID option:selected").text() == "- Select -")
$('img.popButton').button({ disabled: true })
else if ($("#ddlID option:selected").text() == "Option1")
$('img.itemgridimg').button({ disabled: false });
else if ("#ddlID option:selected").text() == "Option2")
$('img.itemgridimg').button({ disabled: true });
else if ("#ddlID option:selected").text() == "Option3")
$('img.itemgridimg').button({ disabled: true });
else if ("#ddlID option:selected").text() == "Option4")
$('img.itemgridimg').button({ disabled: false });
});
I was hoping that this would completely disable the onClick event for the button, but it only changes the visual state of the button (based on the ui-diabled class), but the popup window is still activated.
As I stated before, the popup is called via a dynamically generated onClick event inside the image tag. How do I stop the popup event from firing when a user selects options 2 or 3 only?
UPDATE:
It is definitely a better approach to simply hide the button based on certain selections from drop down, but now, I would like to dynamically insert a new image while the other div is hidden. I thought this would be a simple equation, but I am making an error some where…I can't insert the image in the old div because it is hidden, so how do I dynamically insert a new div with the alternate image? My updated code is below, but I am getting an error because of the function…any suggestions?
$('img.itemgridimg').hide();
$("[id][name*='Status']:eq(0)").change(function () {
if ($("[id][name*='Status']:eq(0) option:selected").text() == "- Select -")
$('img.itemgridimg').eq(0).hide();
$("<div/>",{
"html" : "<img src='../Images/btnOff.png'>"
}); // <---- bad code…need help
else if ($("[id][name*='Status']:eq(0) option:selected").text() == "Missing")
$('img.itemgridimg').eq(0).show();
else if ($("[id][name*='Status']:eq(0) option:selected").text() == "Not Applicable")
$('img.itemgridimg').eq(0).hide();
else if ($("[id][name*='Status']:eq(0) option:selected").text() == "Functional / Acceptable As Is")
$('img.itemgridimg').eq(0).hide();
else if ($("[id][name*='Status']:eq(0) option:selected").text() == "Needs Repair/Replace/Cleaning")
$('img.itemgridimg').eq(0).show();
});
If you truly have no control over the onclick handler of the <img /> then I would simply hide the image whenever Option2 or Option3 is selected. From a usability perspective I've found that users get confused by disabled UI items, so I usually end up hiding controls that they cannot interact with anyways.
You can do this with the following.
$('#selID').on('change', function() {
var value = $(this).val();
if (value == 'Option2' || value == 'Option3') {
$('.popButton').hide();
} else {
$('.popButton').show();
}
});​
Example - http://jsfiddle.net/eNEeC/
For preventing button click to fine try using this:
$('img.popButton').on('click', function(){
return false;
});
or, you can use:
$("img.popButton").click(function(event) {
event.preventDefault();
});
This code will not work:
$("<div/>",{
"html" : "<img src='../Images/btnOff.png'>"
}); // <---- bad code…need help
If this is supposed to create a div and append a child (img), then the approach should be:
$('<div/>').html("<img src='../Images/btnOff.png'>");
The code above will only generate the div. You need to append it to your page where it belongs.
Example:
var my_div = $('<div/>').html("<img src='../Images/btnOff.png'>");
$('body').append(my_div);

Delphi: Can I differentiate between numpad's enter key and carriage return?

I've got a quaint little app that pops up an on screen numberpad/calculator written in Delphi. I'd like to make it so if you pressed 'enter' (on the number pad) you'd be pressing '=' and if you pressed 'return' (on the main keyboard) you'd be pressing 'OK'.
There's an OK button who is the form's default guy which responds to hitting enter or return.
There is also an onkeydown event handler which potentially might capture both Enter and return as vk_return. But its duties are usurped by the default 'OK' button.
If I could know the difference between return and enter, then I could get rid of my default property on the OK button and just do hit the OK button's click event handler on the form key down function, but alas they are both VK_RETURN.
Override the WM_KEYDOWN message handler:
procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
Implement it so that it calls the ancestor for anything but what you're interested in. You can detect the difference between the return key and the enter key by the "extended" bit in the key data message field:
procedure TForm1.WMKeyDown(var Message: TWMKeyDown);
const
// Message.KeyData format:
// [0..15 repCount][16..23 scan code][24 extended bit][25..28 reserved]
// [29 context][30 previous state][31 transition state]
KD_IS_EXTENDED = 1 shl 24;
begin
if Message.CharCode <> VK_RETURN then
begin
inherited;
Exit;
end;
if (KD_IS_EXTENDED and Message.KeyData) <> 0 then
ShowMessage('Keypad Enter')
else
ShowMessage('Return');
end;

Resources