Jump to content

How do I add a Custom Button (far right) to the uniMainmForm Caption Bar


andyhill

Recommended Posts

Hi,

 

Look at this demo:

\FMSoft\Framework\uniGUI\Demos\Touch\TitleButtons
MainmForm -> TitleButtons

procedure TMainmForm.UnimFormTitleButtonClick(Sender: TUnimTitleButton);
begin
  case Sender.ButtonId of
    0 :     
    1 : 
  end;
end;

Best regards,

Link to comment
Share on other sites

Hi,

 

3) Can I place a DatePicker on the TitleBar ?

 

You can try this approach:

procedure TMainmForm.UnimFormReady(Sender: TObject);
begin
  UniSession.AddJS('MainmForm.titlebar.insert(2, {xtype: "datepickerfield", value: new Date()});');
end;
Link to comment
Share on other sites

Fantastic, now all I need is to capture the date change in Delphi plus set the date in Delphi.

 

For example:

procedure TMainmForm.UnimFormReady(Sender: TObject);
begin
  UniSession.AddJS('MainmForm.titlebar.insert(2, {xtype: "datepickerfield", value: new Date(), listeners: {change: function(el, v){ajaxRequest(MainmForm.form, "_change", [])}}});');
end;
procedure TMainmForm.UnimFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_change' then
    ShowMessage('change');

end;

And try to use like this approach:

http://forums.unigui.com/index.php?/topic/9298-unidbgrid-tray-add-objects-buttons/&do=findComment&comment=48258

Link to comment
Share on other sites

I am still trying to TitleBar Right Align Button ?

 

UniSession.AddJS('MainmForm.titlebar.insert(2, {xtype: "button", text: 'Today', id: "syncDatesID", listeners: {tap: function(el, v) {ajaxRequest(MainmForm.form, "_syncButton", [])}}});');
 
Please advise.
Link to comment
Share on other sites

Hi,

 

You can follow this sequence:

 

 

1. Let's say MainmForm -> TitleButtons = [] - "isEmpty"

 

2. MainmForm -> TitleButtons -> add

 

"0 - TUnimTitleButton-0": -> Separator=True

 

3. Just for information: TitleBar -> items[0] - this is MainmForm.Caption

 

4. Now we have two items:

 

items[0] -> MainmFormCaption

items[1] -> "Separator"

 

5. By specifying the index <= 1, the item will be located on the left side, otherwise on the right...

MainmForm.titlebar.insert(Index, {});

This is one of the possible solutions, try...

 

Best regards,

Link to comment
Share on other sites

I need "Today" button on Right, your suggestion does not work nor the other half dozen I have tried - Please advise.

 

iPhone2.jpg

 

  UniSession.AddJS('MainmForm.titlebar.insert(2, '+
  '{ '+
     'xtype: "button", '+
     'text: '+QuotedStr('Today')+', '+
     'id: "syncTodayID", '+
     'listeners: {tap: function(el, v) {ajaxRequest(MainmForm.form, "_syncToday", [])}}'+
  '} );');
 
 

 

TitleBar2.png

Link to comment
Share on other sites

procedure TMainmForm.UnimFormReady(Sender: TObject);
begin
  UniSession.AddJS('MainmForm.titlebar.insert(2, '+
  '{ '+
     'xtype: "spacer"'+
  '} );');

  UniSession.AddJS('MainmForm.titlebar.insert(3, '+
  '{ '+
     'xtype: "button", '+
     'text: '+QuotedStr('Today')+', '+
     'id: "syncTodayID", '+
     'listeners: {tap: function(el, v) {ajaxRequest(MainmForm.form, "_syncToday", [])}}'+
  '} );');
end;
Link to comment
Share on other sites

×
×
  • Create New...