I have a custom dialog page that contains a text box. When the user hits the "Next" button, I want to make sure that there is text in the text box before allowing the installation to continue.
How can this be done? I tried adding a check in nsDialogsPageLeave, where I call nsDialogsPage if the validation fails, but this does not work...the buttons at the bottom of the page are not active after it reloads.
Var Dialog
Var Text
Var Text_State
Page custom nsDialogsPage nsDialogsPageLeave
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateText} 0 0 50% 12u $Text_State
Pop $Text
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetText} $Text $Text_State
FunctionEnd
The way I've dealt with this situation is to validate the text in the leave function so that your code becomes:
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateText} 0 0 50% 12u $Text_State
Pop $Text
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetText} $Text $Text_State
${If} $Text_State == ""
MessageBox MB_OK "Please enter some text"
Abort
${EndIf}
FunctionEnd
This way the user can click the Next button but they will get an error message if no text has been entered and the Abort will stop the installer moving to the next page.
Related
In the application I'm working on, there is a TListView and a TRichEdit in a form.
When the user click an item in the TListView, it loads TRichEdit text. My problem occurs when the text is longer then the height of the TRichEdit.
If I scroll with the Mouse Wheel really quickly and I continue scrolling even when the scrolling bar is at bottom, then I click another item in the TListview (which make TRichEdit->Text change), the scrolling sometimes continues on the newly loaded text.
My hypothesis is that there is some kind of Windows Message not yet processed and when I click another item, the scroll message is read and the scrolling continue?!
I already tried to disable then enable the TRichEdit on the TRichEdit MouseLeave without success (scrolling continue when I change selected item of TListView).
I was wondering if anybody have any ideas?
[edit]
Ok so I'm trying the solution from Remy but PeekMessage() doesn't catch any WM_VSCROLL, WM_HSCROLL, WM_MOUSEWHEEL. I tried to catch it before and after the function DescriptionChanged(); but neither of them catch the scroll message.
void __fastcall TfrmJob::lvDescriptionSelectItem(TObject *Sender, TListItem *Item, bool Selected)
{
//Function where ListView load item into RichEdit->Text
DescriptionChanged();
MSG msg;
//Loop while there is messages ("If no messages are available, the return value is zero")
while (PeekMessage(&msg, NULL /*reDocDetail->Handle*/ /*lvDescription->Handle*/, 0, 0, PM_REMOVE | PM_QS_INPUT) > 0)
{
//Trying to catch Scroll message
if(msg.message == WM_VSCROLL || msg.message == WM_HSCROLL || msg.message == WM_MOUSEWHEEL)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
}
https://api.jquerymobile.com/filterable/
there seems to be a problem with the implementation of this widget in that, if you are typing into the text field, then press enter nothing happens, but then your next key press has no effect. eg:
focus on text field
press a ('a' appears in field)
press enter (no change)
press a (no change)
press a ('aa' appears in field)
I have logged an issue, however doubt it will get attention in the short term. Anyone suggest a work around?
At least we can tell JQM to restore the _preventKeyPress flag by simulating another keypress:
$(document).on("keyup", ".ui-input-search>input", function(e) {
var key = e.keyCode ? e.keyCode : e.which ? e.which : 0;
if(key == 13) {
$(this).trigger(jQuery.Event("keypress", {
srcElement: this,
bubbles: true,
cancelable: true,
which: 0,
keyCode: 0,
charCode: 0,
target: this,
currentTarget: this,
eventPhase: 2, // AT TARGET
type: "keypress",
view: e.view,
returnValue: true
}));
}
});
EDIT:
Just for the sake of completeness, here is the solution from Omar:
https://github.com/jquery/jquery-mobile/issues/8571#issuecomment-300430818
I would like to use Greasemonkey to access some API objects of youtube videos while I'm in fullscreen mode.
It could be useful to have mouse clicks and position relative to screen.
This, to detect fullscreen mode, doesn't work:
window.fullScreen
I tried also to add mouse event detection to yt player, with this:
var player = document.getElementById('movie_player');
player.addEventListener("click", interceptClicks,true);
but it doesn't fire that func.
I tried also to inject some code like this:
function GM_main () {
var playerNode = document.getElementById ("movie_player");
playerNode.addEventListener ('click', interceptClicks ,false);
}
addJS_Node (null, null, GM_main);
function addJS_Node (text, s_URL, funcToRun, runOnLoad) {
var D = document;
var scriptNode = D.createElement ('script');
if (runOnLoad) {
scriptNode.addEventListener ("load", runOnLoad, false);
}
scriptNode.type = "text/javascript";
if (text) scriptNode.textContent = text;
if (s_URL) scriptNode.src = s_URL;
if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
targ.appendChild (scriptNode);
}
I tried also to make a:
window.addEventListener('click', interceptClicks, false);
This works, BUT only in all areas different from the youtube flash player in non-fullscreen mode and in fullscreen mode, obviously none area, as there is only the player visible...
EDIT:
I made a partial progress indeed.
I created a button element with
btn.addEventListener("click", function () { player.mozRequestFullScreen();}, false)
This way flash video enters in Firefox fullscreen mode and so it receives the wheel events fired by the
window.addEventlistener('DOMMouseScroll', .....etc)
Besides, the fullscreen mode is detected by
window.fullScreen
Also, all keys (event) are detectable, but ESC; not again the mouse clicks..
There is a drawback:
Once in fullscreen, SOMETIMES if you click the left mouse button it suddenly exits fullscreen mode... SOMETIMES instead it stays normally full...
To exit it's not sufficient to press ESC, you need to press the normal flash fullscreen button on the lower right + ESC.
Some rare times it blocks itself in Fullscreen mode and you can't exit. You should press ctrl+alt+canc and then it appears firefox "block script" dialog box.
Why that odd behaviour and how to prevent it?
Ideally the best should be: intercept mouse click on the lower right flash fullscreen button, block it, redirect the call to mozFullscreen and block the fullscreen mode until you press ESC.
But I dont' think it's possible, is it?
Why does a Delphi StringGrid sometimes calls the OnClick event after an OnKeyDown?
Debugging screenshot:
My OnKeyDown event handler:
var
Top: Integer;
Bottom: Integer;
CurrentRow: Integer;
begin
Top := Grid.TopRow;
Bottom := Grid.TopRow + Grid.VisibleRowCount - 1;
if (Key = 38) then CurrentRow := Grid.Row - 1
else if (Key = 40) then CurrentRow := Grid.Row + 1;
// Disable OnClick because sometimes a 'TStringGrid.Click' is called anyway...
// (when clicking on form top window bar and navigating)
Grid.OnClick := nil;
if (CurrentRow < Top - 1) or (CurrentRow > Bottom + 1) then begin
if (Key = 38) then Grid.Row := Bottom
else if (Key = 40) then Grid.Row := Top;
end;
Grid.OnClick := GridClick;
end;
Edit:
It seems the 'OnClick' is not being fired when the last line is selected and pushing 'Down' or when the first line is selected and pushing 'Up'.
Way to reproduce:
Add a TStringGrid to a form and populate with a few lines. Add 'OnClick' and 'OnKeyDown' handler. No specific code needs to be added in these two handler methods. Select a row in the stringgrid on the form and press the up or down arrow on your keyboard.
Edit 2:
This isn't the solution, but to prevent the code in 'OnClick' being executed after pressing up, down, pageup or pagedown, I set a variable in 'OnKeyDown' what key was pressed and check for that variable in 'OnClick'.
Edit 3:
Updated stack trace and way to reproduce.
Well, that hard-coded key codes aren't the case making the least bit transparent, but you witness this effect when you use a direction key (up, down, left, etc...) to change the selection.
Why the OnClick event handler is called, is because TCustomGrid.OnKeyDown calls TCustomGrid.FocusCell, which calls Click.
Exactly why changing focus to another cell would establish a click I do not know, we would have to ask the developers I imagine. Perhaps to simulate the default behaviour when changing focus to another cell by clicking instead of keyboard.
Since you seem to handle direction key presses yourself, maybe you could consider to prevent this from happening at all by ignoring the key any further:
if Key in [VK_PRIOR..VK_DOWN] then
Key := 0;
i've got the following code taken and slightly modified by the original example page:
http://jsfiddle.net/zK3Wc/21/
somehow, if you use the arrow down button to go through the list, it shows the values (digits) in the search field, instead of the label, but the code says, that on the select event, the label should be set as the value.
what i would need is to display the label in the searchfield instead of the digits, but if i click on an item, it has the digit value in the url, the same when using the arrow down button.
Ramo
Add a focus event:
focus: function( event, ui ) {
$( ".project" ).val( ui.item.label );
return false;
},
http://jsfiddle.net/zK3Wc/26/
For me, I forgot to put return false; in the select: callback function