コピーボタンの表示

このサンプルでは日付時刻コントロールにコピーボタンの表示を設定することができます。表示したコピーボタンをクリックすると入力した値がクリップボードにコピーされます。また、コピーするときにリテラル文字を含むかどうかのオプションを設定することができます。

日付時刻コントロール内にコピーボタンを表示する機能について解説します。 コピーボタンを表示する方法 コピーボタンをクリックすると、入力されている値をクリップボードにコピーします。 コピーボタンを表示するには、コンストラクタの showCopyButton オプションに true を設定します。 また、copyMessage/copiedMessage オプションを使用することで、ツールチップに表示するテキストを設定することができます。 なお、テキストの一部を選択してコピーボタンを押下する場合、選択テキストのみコピーします。 テキストを選択しない場合、すべてのテキストをコピーします。 注意事項 ClipContent設定値によって、クリップボードにコピーされるテキストが異なります。 値 説明 IncludeLiterals リテラル文字列を含む(デフォルト) ExcludeLiterals リテラル文字列を含まない useClipboardがfalseに設定される場合は、クリップボードアクセスすることを許可しないため、コピーボタンが表示されません。 コントロールを無効にするときに、表示するコピーボタンも無効になります。
import { bootstrapApplication } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { InputManModule } from "@mescius/inputman.angular"; import '@mescius/inputman/CSS/gc.inputman-js.css'; import './styles.css'; import { Component, enableProdMode, ViewChild } from '@angular/core'; import { GcDateTimeComponent } from '@mescius/inputman.angular'; import { InputMan } from '@mescius/inputman'; @Component({ selector: 'app-component', templateUrl: './src/app.component.html', imports: [InputManModule, BrowserModule, FormsModule], standalone: true }) export class AppComponent { ngOnInit(): void { InputMan.appearanceStyle = InputMan.AppearanceStyle.Modern; } @ViewChild("textbox1") textbox1: GcDateTimeComponent; @ViewChild("textbox2") textbox2: GcDateTimeComponent; public showCopyButton01 = true; public showCopyButton02 = true; readonly clipContent = [ InputMan.ClipContent.ExcludeLiterals, InputMan.ClipContent.IncludeLiterals, ]; showCopyButton(e: Event) { this.showCopyButton01 = e.target.checked; this.showCopyButton02 = e.target.checked; } setClipContent(e: Event) { this.textbox1.getNestedIMControl().setClipContent(e.target.checked ? this.clipContent[0] : this.clipContent[1]); this.textbox2.getNestedIMControl().setClipContent(e.target.checked ? this.clipContent[0] : this.clipContent[1]); } useClipboard(e: Event) { this.textbox1.getNestedIMControl().setUseClipboard(e.target.checked); this.textbox2.getNestedIMControl().setUseClipboard(e.target.checked); } enableControl(e: Event) { this.textbox1.getNestedIMControl().setEnabled(e.target.checked); this.textbox2.getNestedIMControl().setEnabled(e.target.checked); } } enableProdMode(); bootstrapApplication(AppComponent).catch(err => console.error(err));
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>日付時刻コントロール - コピーボタンの表示</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/fesm2015/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle window.onload = function() { System.import('rxjs').then(function (m) { System.import('@angular/compiler'); System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); } </script> </head> <body> <app-component></app-component> </body> </html>
<div> <gc-datetime #textbox1 [showCopyButton]="showCopyButton01" copyMessage="日付時刻をコピーします" copiedMessage="コピーしました"></gc-datetime> </div> <br> <div> ツールチップのスタイルを変更する<br> <gc-datetime #textbox2 [showCopyButton]="showCopyButton02" copyMessage="日付時刻をコピーします" copiedMessage="コピーしました" class="custom"></gc-datetime> </div> <table class="sample"> <tr> <th>コピーボタンの表示</th> <td> <label><input type="checkbox" (click)="showCopyButton($event)" checked />表示する</label> </td> </tr> <tr> <th>リテラル</th> <td> <label><input type="checkbox" (click)="setClipContent($event)" />リテラル文字列を含まない</label> </td> </tr> <tr> <th>クリップボードアクセス</th> <td> <label><input type="checkbox" (click)="useClipboard($event)" checked />クリップボードアクセスすることを許可する</label> </td> </tr> <tr> <th>コントロール</th> <td> <label><input type="checkbox" (click)="enableControl($event)" checked />有効</label> </td> </tr> </table>
body { padding-bottom: 10rem; } .gcim { width: 180px; } .custom .gcim__copy-button_tip { background-color: lightblue; font-weight: bold; }
body { padding-bottom: 10rem; } [gcim-control-appearance="modern"] .gcim { width: 180px; } [gcim-control-appearance="modern"] .custom .gcim__copy-button_tip { background-color: lightblue; font-weight: bold; }
(function (global) { System.config({ transpiler: 'ts', typescriptOptions: { tsconfig: true }, meta: { 'typescript': { "exports": "ts" }, '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { 'core-js': 'npm:core-js/client/shim.min.js', 'zone': 'npm:zone.js/fesm2015/zone.min.js', //'reflect-metadata': 'npm:reflect-metadata/Reflect.js', 'rxjs': 'npm:rxjs/dist/bundles/rxjs.umd.min.js', //'rxjs': 'npm:rxjs', //'rxjs/operators': 'npm:rxjs/operators', '@angular/core': 'npm:@angular/core/fesm2022', '@angular/common': 'npm:@angular/common/fesm2022/common.mjs', '@angular/compiler': 'npm:@angular/compiler/fesm2022/compiler.mjs', '@angular/platform-browser': 'npm:@angular/platform-browser/fesm2022/platform-browser.mjs', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/fesm2022/platform-browser-dynamic.mjs', '@angular/common/http': 'npm:@angular/common/fesm2022/http.mjs', '@angular/router': 'npm:@angular/router/fesm2022/router.mjs', '@angular/forms': 'npm:@angular/forms/fesm2022/forms.mjs', '@mescius/inputman': 'npm:@mescius/inputman/index.js', '@mescius/inputman.angular': 'npm:@mescius/inputman.angular/fesm2015/mescius-inputman.angular.mjs', '@mescius/inputman.richtexteditor': 'npm:@mescius/inputman.richtexteditor/index.js', '@mescius/inputman.richtexteditor.angular': 'npm:@mescius/inputman.richtexteditor.angular/fesm2015/mescius-inputman.richtexteditor.angular.mjs', '@mescius/inputman.comment': 'npm:@mescius/inputman.comment/index.js', '@mescius/inputman.comment.angular': 'npm:@mescius/inputman.comment.angular/fesm2015/mescius-inputman.comment.angular.mjs', '@mescius/inputman/CSS': 'npm:@mescius/inputman/CSS', "@mescius/inputman.richtexteditor/CSS": "npm:@mescius/inputman.richtexteditor/CSS", '@mescius/inputman.richtexteditor/JS/plugins/advlist': 'npm:@mescius/inputman.richtexteditor/JS/plugins/advlist/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/all': 'npm:@mescius/inputman.richtexteditor/JS/plugins/all/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/autosave': 'npm:@mescius/inputman.richtexteditor/JS/plugins/autosave/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/charmap': 'npm:@mescius/inputman.richtexteditor/JS/plugins/charmap/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/directionality': 'npm:@mescius/inputman.richtexteditor/JS/plugins/directionality/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/emoticons': 'npm:@mescius/inputman.richtexteditor/JS/plugins/emoticons/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/fullscreen': 'npm:@mescius/inputman.richtexteditor/JS/plugins/fullscreen/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/htmlcode': 'npm:@mescius/inputman.richtexteditor/JS/plugins/htmlcode/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/image': 'npm:@mescius/inputman.richtexteditor/JS/plugins/image/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/link': 'npm:@mescius/inputman.richtexteditor/JS/plugins/link/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/lists': 'npm:@mescius/inputman.richtexteditor/JS/plugins/lists/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/media': 'npm:@mescius/inputman.richtexteditor/JS/plugins/media/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/pagebreak': 'npm:@mescius/inputman.richtexteditor/JS/plugins/pagebreak/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/preview': 'npm:@mescius/inputman.richtexteditor/JS/plugins/preview/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/save': 'npm:@mescius/inputman.richtexteditor/JS/plugins/save/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/searchreplace': 'npm:@mescius/inputman.richtexteditor/JS/plugins/searchreplace/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/table': 'npm:@mescius/inputman.richtexteditor/JS/plugins/table/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/template': 'npm:@mescius/inputman.richtexteditor/JS/plugins/template/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/wordcount': 'npm:@mescius/inputman.richtexteditor/JS/plugins/wordcount/plugin.js', '@mescius/inputman.comment/CSS': 'npm:@mescius/inputman.comment/CSS', '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ja': 'npm:@mescius/spread-sheets-resources-ja/index.js', '@mescius/spread-sheets/styles': 'npm:@mescius/spread-sheets/styles', '@mescius/wijmo': 'npm:@mescius/wijmo/index.js', '@mescius/wijmo.styles': 'npm:@mescius/wijmo.styles', '@mescius/wijmo.cultures': 'npm:@mescius/wijmo.cultures', '@mescius/wijmo.nav': 'npm:@mescius/wijmo.nav/index.js', '@mescius/wijmo.grid': 'npm:@mescius/wijmo.grid/index.js', '@mescius/wijmo.input': 'npm:@mescius/wijmo.input/index.js', 'bootstrap.css': 'npm:bootstrap/dist/css/bootstrap.min.css', 'jszip': 'npm:jszip/dist/jszip.min.js', 'typescript': 'npm:typescript/lib/typescript.js', 'ts': './plugin.js', 'tslib': 'npm:tslib/tslib.js', 'css': 'npm:systemjs-plugin-css/css.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'ts', meta: { "*.component.ts": { loader: "system.component-loader.js" } } }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' }, "@mescius/inputman": { defaultExtension: 'js' }, "@mescius/inputman.richtexteditor": { defaultExtension: 'js' }, "@mescius/inputman.comment": { defaultExtension: 'js' }, "node_modules/@angular": { defaultExtension: 'mjs' }, "@mescius/inputman.angular": { defaultExtension: 'mjs' }, "@mescius/inputman.comment.angular": { defaultExtension: 'mjs' }, '@angular/core': { defaultExtension: 'mjs', main: 'core.mjs' }, "@mescius/inputman.richtexteditor.angular": { defaultExtension: 'mjs' }, } }); })(this);