数値コントロールには、数値入力に特化した簡易キーパッドをドロップダウン表示することが可能です。
概要
数値コントロールのaddDropDownNumericPadメソッドを実行すると、ドロップダウンボタンの押下により、数値入力に特化した簡易キーパッドが表示されます。
数値パッドは数字キーをクリックまたはタップすることで、コントロールに直接数字を入力できます。入力完了後はドロップダウンボタンの再押下か、ドロップダウン部分以外の箇所をクリックすることで数値パッドは閉じられます。
数値パッドは、以下のキーから構成されます。
0~9までの数字キー
左右移動キー(「<」「>」)
Baskspaceキー(「」)
ピリオドキー(「.」)
正負切り替えキー(「+/-」)
ドロップダウン操作
コントロールがフォーカスを取得したときに自動的にドロップダウンを開くには、引数にtrueを指定してsetAutoDropDownメソッドを実行します。
任意のタイミングで手動でドロップダウンを開くには、ドロップダウンウィンドウ(getDropDownWindowメソッドで取得します)のopenメソッドを実行します。また、ドロップダウンを開くにはcloseメソッドを実行します。
ドロップダウンボタン
ドロップダウンボタンの表示有無は、setDropDownButtonVisibleメソッドで設定することが可能です。引数をtrueに設定すると、ドロップダウンボタンが表示されます。(既定値はtrueです。)
ドロップダウンの方向
ドロップダウンは通常コントロールの下に表示されますが、コントロールの下にドロップダウンを表示できる十分なスペースがない場合は、ドロップダウンがコントロールの上に表示されます。ドロップダウンの表示スペースを判定するとき、既定ではWebページ本体(body要素)をコンテナとして扱いますが、setContainerメソッドで任意の要素をコンテナとして指定することも可能です。
ドロップダウンのアニメーション効果
ドロップダウンリストを表示/非表示を切り替えるときに、アニメーション効果を設定することができます。コントロール全体に一括適用するか、各コントロールに異なるアニメーション効果を設定できます。animationTypeプロパティに設定できる値は以下のとおりで、既定値はDropDownAnimationType.Noneです。
値
アニメーション効果
None
効果なし
SlideDown
スライドダウン
SlideUp
スライドアップ
Popup
ポップアップ要素
Expand
拡大表示
次のサンプルコードは、すべてのコントロールのドロップダウンにアニメーション効果を適用します。
次のサンプルコードは、指定コントロールのドロップダウンにアニメーション効果を適用します。
import { bootstrapApplication } from '@angular/platform-browser';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { InputManModule } from "@mescius/inputman.angular";
import './styles.css';
import '@mescius/inputman/CSS/gc.inputman-js.css';
import { Component, enableProdMode } from '@angular/core';
import * as GC from "@mescius/inputman";
@Component({
selector: 'app-component',
templateUrl: './src/app.component.html',
imports: [InputManModule, BrowserModule, FormsModule],
standalone: true
})
export class AppComponent {
ngOnInit(): void {
GC.InputMan.appearanceStyle = GC.InputMan.AppearanceStyle.Modern;
}
public animationType = [
GC.InputMan.DropDownAnimationType.None,
GC.InputMan.DropDownAnimationType.SlideDown,
GC.InputMan.DropDownAnimationType.SlideUp,
GC.InputMan.DropDownAnimationType.Popup,
GC.InputMan.DropDownAnimationType.Expand,
];
public autoDropDown: boolean;
public dropDownButtonVisible: boolean;
public gcNumber1: GC.InputMan.GcNumber;
public gcNumber2: GC.InputMan.GcNumber;
public toggleDropDown(isOpen: boolean) {
if (isOpen) {
this.gcNumber1.getDropDownWindow().open();
this.gcNumber2.getDropDownWindow().open();
}
else {
this.gcNumber1.getDropDownWindow().close();
this.gcNumber2.getDropDownWindow().close();
}
}
public updateAnimationType(animationType: GC.InputMan.DropDownAnimationType) {
this.gcNumber1.getDropDownWindow().animationType = animationType;
this.gcNumber2.getDropDownWindow().animationType = animationType;
}
}
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 class="flexbox">
<div id="container1" #container1>
<p>ドロップダウンが下に表示されます。</p>
<gc-number (onInitialized)="gcNumber1=$event" [displayFormatDigit]="'##,##0'" [displayPositivePrefix]="'税込 '"
[displayNegativePrefix]="'税込 ▲'" [displayPositiveSuffix]="'円'" [displayNegativeSuffix]="'円'"
[formatDigit]="'#####'" [positivePrefix]="'$'" [negativePrefix]="'-$'" [positiveSuffix]="'(税込)'"
[negativeSuffix]="'(税込)'" [showNumericPad]="true" [autoDropDown]="autoDropDown"
[dropDownButtonVisible]="dropDownButtonVisible" [container]="container1"></gc-number>
</div>
<div id="container2" #container2>
<p>ドロップダウンが上に表示されます。</p>
<gc-number (onInitialized)="gcNumber2=$event" [displayFormatDigit]="'##,##0'" [displayPositivePrefix]="'税込 '"
[displayNegativePrefix]="'税込 ▲'" [displayPositiveSuffix]="'円'" [displayNegativeSuffix]="'円'"
[formatDigit]="'#####'" [positivePrefix]="'$'" [negativePrefix]="'-$'" [positiveSuffix]="'(税込)'"
[negativeSuffix]="'(税込)'" [showNumericPad]="true" [autoDropDown]="autoDropDown"
[dropDownButtonVisible]="dropDownButtonVisible" [container]="container2"></gc-number>
</div>
</div>
<table class="sample">
<tr>
<th>フォーカス時のドロップダウン操作</th>
<td>
<label><input type="checkbox" id="openOnFocus"
(change)="autoDropDown=$event.target.checked">フォーカス時にドロップダウンを開く</label>
</td>
</tr>
<tr>
<th>コードによるドロップダウン操作</th>
<td>
<button id="open" (click)="toggleDropDown(true)">ドロップダウンを開く</button>
<button id="close" (click)="toggleDropDown(false)">ドロップダウンを閉じる</button>
</td>
</tr>
<tr>
<th>ドロップダウンボタンの表示</th>
<td>
<label><input type="checkbox" id="setDropDownButtonVisible" checked
(change)="dropDownButtonVisible=$event.target.checked">ドロップダウンボタンを表示する</label>
</td>
</tr>
<tr>
<th>アニメーション効果</th>
<td>
<select (change)="updateAnimationType(animationType[$event.target.selectedIndex])">
<option selected>なし</option>
<option>スライドダウン</option>
<option>スライドアップ</option>
<option>ポップアップ</option>
<option>拡大</option>
</select>
</td>
</tr>
</table>
.flexbox {
display: flex;
flex-wrap: wrap;
}
.flexbox>div {
height: 300px;
width: 300px;
background-color: #f8f8f8;
}
#container2>p {
margin-top: 220px;
}
[gcim-control-appearance="modern"] .flexbox {
display: flex;
flex-wrap: wrap;
}
[gcim-control-appearance="modern"] .flexbox>div {
height: 300px;
width: 300px;
background-color: #f8f8f8;
}
[gcim-control-appearance="modern"] #container2>p {
margin-top: 220px;
}
(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);