Jump to content

how to add a TUniFileUploadButton in a menu


delagoutte

Recommended Posts

procedure TUMM.UniGUIMainModuleNewComponent(AComponent: TComponent);
var
  c1, c2 : string;
begin
  if (AComponent is TUnimFileUploadButton) then
    begin
      if AnsiUpperCase(dMotyw) = 'ZIELONY'then
        begin
          c1 := '#53af48';
          c2 := '#53af48';
        end
      else
        begin
          c1 := 'rgb(33, 150, 243)';
          c2 := 'rgb(18 128 215)';
        end;

       with (AComponent as TUnimFileUploadButton), JSInterface do
        begin
          JSCallGlobal('Ext.util.CSS.createStyleSheet', ['#'+JSId+' .x-inner-el{ '+
            ' background-color: white; '+
            ' border-color: '+c1+'; '+
            ' border-width: 2px; '+
            '}'+
            '#'+JSId+' .x-text-el{ '+
            ' color: '+c2+'; '+
            ' font-weight: #525452; '+
            '}'+
            '#'+JSId+' .x-label-el{ '+
            ' display: none; '+
            '}'+
            '#'+JSId+' .x-input-el{ '+
            ' display: none; '+
            '}'+
            '#'+JSId+' .x-input-wrap-el{ '+
            ' border: none; '+
            '}'+
            '#'+JSId+' .x-after-input-el{ '+
            ' width: 100%; '+
            ' background-color: white; '+
            '}'+
            '#'+JSId+' .x-filetrigger{ '+
            ' width: 100%; '+
            //      ' margin-left: 1em; '+
            '}'+
            '#'+JSId+' .x-button-action{ '+
            ' width: 100%; '+
            ' height: 100%; '+
            '}'+
            '#'+JSId+' .x-field{ '+
            ' width: 100% !important; '+
            '}'
            ]);
        end;
    end;

//
end;

Above is code in MainModule - adding styles

And this can change text of the button:

  UnimFileUploadButton1.JSInterface.JSAssign('element.dom.querySelector(".x-text-el").innerText', ['Upload file']);


 

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, PS1 said:
procedure TUMM.UniGUIMainModuleNewComponent(AComponent: TComponent);
var
  c1, c2 : string;
begin
  if (AComponent is TUnimFileUploadButton) then
    begin
      if AnsiUpperCase(dMotyw) = 'ZIELONY'then
        begin
          c1 := '#53af48';
          c2 := '#53af48';
        end
      else
        begin
          c1 := 'rgb(33, 150, 243)';
          c2 := 'rgb(18 128 215)';
        end;

       with (AComponent as TUnimFileUploadButton), JSInterface do
        begin
          JSCallGlobal('Ext.util.CSS.createStyleSheet', ['#'+JSId+' .x-inner-el{ '+
            ' background-color: white; '+
            ' border-color: '+c1+'; '+
            ' border-width: 2px; '+
            '}'+
            '#'+JSId+' .x-text-el{ '+
            ' color: '+c2+'; '+
            ' font-weight: #525452; '+
            '}'+
            '#'+JSId+' .x-label-el{ '+
            ' display: none; '+
            '}'+
            '#'+JSId+' .x-input-el{ '+
            ' display: none; '+
            '}'+
            '#'+JSId+' .x-input-wrap-el{ '+
            ' border: none; '+
            '}'+
            '#'+JSId+' .x-after-input-el{ '+
            ' width: 100%; '+
            ' background-color: white; '+
            '}'+
            '#'+JSId+' .x-filetrigger{ '+
            ' width: 100%; '+
            //      ' margin-left: 1em; '+
            '}'+
            '#'+JSId+' .x-button-action{ '+
            ' width: 100%; '+
            ' height: 100%; '+
            '}'+
            '#'+JSId+' .x-field{ '+
            ' width: 100% !important; '+
            '}'
            ]);
        end;
    end;

//
end;

Above is code in MainModule - adding styles

And this can change text of the button:

  UnimFileUploadButton1.JSInterface.JSAssign('element.dom.querySelector(".x-text-el").innerText', ['Upload file']);


 

extremely helpful, thank you so much, @PS1.

Does anyone have an idea, how to place an image into that button and remove the border. Then I would be completely happy!

Link to comment
Share on other sites

Try this

1. Border

You can change style in my code, by setting ,,border-width: 0px"

2.Image

Try  writing some html with image instead of just text in code below (you can use <img> too for your pictures)

UnimFileUploadButton1.JSInterface.JSAssign('element.dom.querySelector(".x-text-el").innerText', ['TEST<i class="fa fa-arrow-up" style="margin-right: 4px;"></i>']);
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...