Hi,
When using a content region on a message box, there is no way to specify which control receives focus when the box is displayed. It defaults to the default button. For data entry, it would be great to control where the cursor begins. This would be a useful feature for your list.
I have implemented it using the following code if this is helpful.
.RenderHTML modified as follows:
//ML!!
if Assigned(FMLFocusControl)
then html := html + HTMLName + 'ContentFocusControl="'+FMLFocusControl.HTMLName+'";'#13
else html := html + HTMLName + 'ContentFocusControl="";'#13;
//ML!!
if Assigned(FMLFocusControl)
then html := html + HTMLName + 'ContentFocusControl="'+FMLFocusControl.HTMLName+'";'#13
else html := html + HTMLName + 'ContentFocusControl="";'#13;
//existing code
html := html
+ 'function ' + HTMLName + 'Focus(){'#13
+ ' input = document.getElementById("' + HTMLName + 'Input1");'#13
+ ' if ((input) && (' + HTMLName + 'DefaultValue == ""))'#13
+ ' input.focus();'#13
+ ' else {'#13
+ ' el = document.getElementById("' + HTMLName + 'b' + IntToStr(DefaultButton) + '");'#13
+ ' if (el){'#13
+ ' el.focus();'#13
+ ' }else{'#13
+ ' document.getElementById("' + HTMLName + 'Dialog").focus();'#13
+ ' }'#13
+ ' }'#13
//ML!!
+ ' if ('+HTMLName + 'ContentRegionID != "") {'#13
+ ' if ('+HTMLName + 'ContentFocusControl != "") {FindElem('+HTMLName + 'ContentFocusControl).select();}'#13
+ ' }'#13 //ML!!
+ 'function ' + HTMLName + 'Focus(){'#13
+ ' input = document.getElementById("' + HTMLName + 'Input1");'#13
+ ' if ((input) && (' + HTMLName + 'DefaultValue == ""))'#13
+ ' input.focus();'#13
+ ' else {'#13
+ ' el = document.getElementById("' + HTMLName + 'b' + IntToStr(DefaultButton) + '");'#13
+ ' if (el){'#13
+ ' el.focus();'#13
+ ' }else{'#13
+ ' document.getElementById("' + HTMLName + 'Dialog").focus();'#13
+ ' }'#13
+ ' }'#13
//ML!!
+ ' if ('+HTMLName + 'ContentRegionID != "") {'#13
+ ' if ('+HTMLName + 'ContentFocusControl != "") {FindElem('+HTMLName + 'ContentFocusControl).select();}'#13
+ ' }'#13 //ML!!
.RenderAsync modified as follows
//ML!!
if Assigned(FMLFocusControl)
then js := js + HTMLName + 'ContentFocusControl="'+FMLFocusControl.HTMLName+'";'#13
else js := js + HTMLName + 'ContentFocusControl="";'#13;
if Assigned(FMLFocusControl)
then js := js + HTMLName + 'ContentFocusControl="'+FMLFocusControl.HTMLName+'";'#13
else js := js + HTMLName + 'ContentFocusControl="";'#13;
//existing code
if ShowDialog then
begin
js := js + HTMLName + 'Show();'#13;
js := js + HTMLName + 'RePosition();'#13;
//ML!! js := js + HTMLName + 'Focus();'#13;
end;
begin
js := js + HTMLName + 'Show();'#13;
js := js + HTMLName + 'RePosition();'#13;
//ML!! js := js + HTMLName + 'Focus();'#13;
end;
js := js + HTMLName + 'InitAsync();'#13;
//ML!!
if ShowDialog then
begin
js := js + HTMLName + 'Focus();'#13;
end;
if ShowDialog then
begin
js := js + HTMLName + 'Focus();'#13;
end;
js := js
+']]>';
+']]>';