|
|
#1 |
|
Guest
Posts: n/a
|
Set Focus to a Field
I'm trying to use the function on the wiki Set Focus to a Control but there is only an abstract function call syntax and no tangible working example and I'm having a hard time figuring out how to call it.
Can someone please help and give me a real simple example that would set the focus to the first text field in a custom dialog? Better yet, add it to the wiki too? Thanks in advance. |
|
|
|
#2 |
|
Moderator
Join Date: Nov 2002
Location: Shropshire, England
Posts: 6,887
|
It is quite simple really.
code: -Stu |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: May 2004
Posts: 38
|
From version 2.24 InstallOptions has native FOCUS flag
|
|
|
|
|
|
#4 |
|
Major Dude
|
NSIS version 2.24 is still to be released
![]() InstallOptions will be v2.45 then. hand by comm@nder21 ---------- WiKi pages:CreateInternetShortcut|Enhanced FindWindow|Parse CSV-Data|Open/Close CD-Drive|Installer without Icon|Vista application compatibility |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Feb 2007
Posts: 47
|
SetFocus is not working can anyone tell me why?
Page custom organisation_id_pre organisation_id_leave function organisation_id_pre strcmp $ALREADY_INSTALLED "YES" 0 +2 abort !insertmacro MUI_HEADER_TEXT "Required Information" "Please enter following required information" InstallOptions: ialog "$PLUGINSDIR\Organisation_id.ini"Pop $HWND_org_id functionend function organisation_id_leave ReadINIStr $0 "$PLUGINSDIR\Organisation_id.ini" 'Field 2' "State" ;l$ip_addr "$PLUGINSDIR\Organisation_id.ini" 'Field 4' "State" ReadINIStr $1 "$PLUGINSDIR\Organisation_id.ini" 'Field 3' "State" ReadINIStr $2 "$PLUGINSDIR\Organisation_id.ini" 'Field 4' "State" ReadINIStr $3 "$PLUGINSDIR\Organisation_id.ini" 'Field 5' "State" ${If} $0 > '255' messagebox mb_ok "IP address not valid from IP field 1" Push "$PLUGINSDIR\Organisation_id.ini" ;Page .ini file where the field can be found. Push "$HWND_org_id" ;Page handle you got when reserving the page. Push "2" ;Field number to set focus. Call SetFocus !insertmacro MUI_INSTALLOPTIONS_SHOW ; WriteINIStr "$PLUGINSDIR\Organisation_id.ini" 'Field 2' 'Flags' 'FOCUS' ; FlushINI $TEMP\something.ini ; !insertmacro MUI_INSTALLOPTIONS_READ $R1 "$PLUGINSDIR\Organisation_id.ini" "Field 2" "HWND" ; SendMessage $R1 ${WM_SETFOCUS} 0 0 ; SendMessage $R1 ${WM_SETTEXT} 0 "STR:8080" ; abort ${EndIf} |
|
|
|
|
|
#6 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
Don't call MUI_INSTALLOPTIONS_SHOW in the leave function. That should only be called in the page callback function (organistaion_id_pre in your case).
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Feb 2007
Posts: 47
|
If i dont display the page again how the chages will get reflect in UI ?
|
|
|
|
|
|
#8 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
If you call Abort, the page isn't left. If you call InstallOptions again, you just create another page with the old settings and will create trouble when the pages are destroyed.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Feb 2007
Posts: 47
|
Then what i should i do to reflect the changes
|
|
|
|
|
|
#10 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
As I said, call Abort.
code: NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
I was able to use this thread to set focus to a known field number, but how do I focus the next button?
|
|
|
|
|
|
#12 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
code: NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
tried a few things, but where in this logic would that go, i've commented out what I have my hacky SetFocus to remove focus from the text object that I have in there:
code: |
|
|
|
|
|
#14 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
Ah, you want the focus to go there right away. I don't think that'd be possible without modifying InstallOptions. But why do it? Since the next button is the default button, it'd still go to the next page when you hit enter.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
that's just it, it doesn't I have call just after the Pop to:
!insertmacro MUI_INSTALLOPTIONS_READ $DLGITEM "eula.ini" "Field 4" "HWND" SetCtlColors $DLGITEM 0x000000 0xFFFFFF Field 4 is my text box, focus is put there and pressing enter doesn't work. |
|
|
|
|
|
#16 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
Have you tried using the FOCUS flag instead?
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#17 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
that's another one, where does the focus flag go for the next button? been trying to do searches here in the forums for about 15-20 minutes, but no examples of where to use the focus flags, etc. pardon my moronic ways...
|
|
|
|
|
|
#18 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
Not for the Next button, for the control you want focus for. Without any settings, the first control should receive focus and the Next button should still be the default button, so pressing enter should still go to the next page.
There is no setting to set focus to the Next button, because there shouldn't be any need to do that. NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#19 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
how do I set the focus flag to one of my controls?
|
|
|
|
|
|
#20 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
Just add Flags=FOCUS in the INI file.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#21 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
ok, I had tried that on the label and link controls just to get the focus off of the text control, but I have to see what's up. thanks.
|
|
|
|
|
|
#22 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
It won't work on those controls. It knows which controls can receive focus and will ignore the flag if they can't. But weren't you saying you wanted the focus on the Next button rather than off it?
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#23 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
yeah, but if I can get the focus off the text control (as I have done with the SetFocus function) then the Next button will behave like the default button and continue when pressing enter.
|
|
|
|
|
|
#24 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
It should behave that way with or without focus.
How about you attach an example? I'm starting to get confused about what exactly happens and what exactly you want. NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#25 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
here's a stripped version of what I'm trying to do, thanks.
|
|
|
|
|
|
#26 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
What's the BackButton plug-in?
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#27 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
oops just remove that puppy
|
|
|
|
|
|
#28 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
Ah, you didn't mention it's a multiline text field. It might have the same bug as with the richedit control where it eats up Enter and Escape even though it doesn't have the ES_WANTRETURN style. Instead of leaving them be, it acts on the dialog manager's behalf and sends WM_COMMAND to IDOK or WM_CLOSE to its parent dialog. But its parent dialog is just a internal dialog which doesn't handle this. Unlike richedit, edit controls don't have EN_MSGFILTER so if it's really the case, it'd require subclassing.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#29 |
|
Junior Member
Join Date: Oct 2002
Posts: 46
|
ok, I'll stick with my SetFocus hack for now, thanks.
|
|
|
|
|
|
#30 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,310
|
Raymond Chen confirms this is the same bug as with the Rich Edit control. His post also links to another post stating the solution, similar to what Sunjammer used for the RichEdit. I need to think how this can be implemented for nsDialogs as you obviously do want the controls eat the Enter key in some cases.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|